Report Parameter Missing a Value

25 06 2009

If you are getting this error when using the SQL Server 2005 Web Forms Report Viewer (ASP.NET) it’s probably because you are using an old version of the report viewer.

Please install the 2005 SP1 version of the Report Viewer Distributable.

http://www.microsoft.com/downloads/details.aspx?familyid=E7D661BA-DC95-4EB3-8916-3E31340DDC2C&displaylang=en

Either that, of your call to rv.ServerReport.SetParameters() doesn’t have a valid report parameter.





Some good JQuery examples

17 06 2009

http://www.slideshare.net/dbert721/introduction-to-jquery-presentation





Forms Services – Schema validation failed for some data items in the form

8 05 2009

If you’re performing data migration, and moving XML nodes around (or generating the form from template.xml or something similar), it will leave xsi:nil=”true” attributes on the nodes.

Then, if you copy these nodes and intend on filling them with information, you need to either remove the xsi:nil attributes, or set them to false.  How do you do it?  It’s quite simple:

XPathNavigator nilField = DOM.SelectSingleNode(”/my:myFields/my:myNilField“);
if (nilField.MoveToAttribute(”nil”,  “http://www.w3.org/2001/XMLSchema-instance”))
    nilField.DeleteSelf();

This essentially selects the field in question, positions the XPathNavigator to point at the nil attribute, and if it exists (or the pointer move succeeds) it will remove the attribute at its current position (aka, itll delete the nil attribute).

This tends to happen with DateTime fields in your schema (more often than not).

Matt





MOSS & WSS SP2 released

28 04 2009




Programatically creating and assigning a SharePoint task

27 04 2009

So we had a requirement where we needed to create and assign a SharePoint task to all site collection administrators upon the creation of a new forms based user.  Essentially, once a user registers it assigns a new Task to all administrators asking them to assign that user to a group.  Those tasks are exposed on the administrators view of the world (a filtered view on their landing page).

Here’s how it’s done.  Firstly, you need to hook the CreatedUser event on the CreateUserWizard control that you used for registering your FBA user.  (I appologise in advance for the poor code formatting).

protected void Page_Load(object sender, EventArgs e)
{
     CreateUserWizard1.CreatedUser += new EventHandler(CreateUserWizard1_CreatedUser);
}

Secondly, you need to define the CreatedUser event:

void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
    // Firstly we elevate our privleges so that we can create and modify tasks.
    SPSecurity.RunWithElevatedPrivleges(delegate {
    // To get the username and password of the created user, access the wizard via the sender
    CreateUserWizard wizard = (CreateUserWizard) sender;
  
    // Now we reference the site – note we need to create a new site object reference so that it uses the elevated context, otherwise we will be executing code as the current user instead of the system user.
    using (SPSite site = new SPSite(SPContext.Current.Site.Url)
    {
                // Now we need to allow safe updates, so we dont get any security validation errors when updating the list item
               site.AllowUnsafeUpdates = true;
               // Now we grab the web object, once again we use openweb on the current site so we stay in system context, and we do it via the using block to ensure that our objects are disposed after we are finished with them
                using(SPWeb web = site.OpenWeb())
                {
                           // Let’s allow safe updates on the web as well
                           web.AllowSafeUpdates = true;
                           // Now we have our context web, we can access the task list
                           SPList tasks = web.Lists["Tasks"];
                           // Call our custom method to create the new tasks for every site collection admin:
                           CreateTasksForAllAdmins(tasks, web, wizard.UserName, wizard.Email);           
                }
     }
});
}

// Now we define a method which goes through all of our site collection admins and creates a new task for each of them

void CreateTasksForAllAdmins(SPList list, SPWeb web, string username, string email)
{
    // Iterate over all of the site users (this include all of our site collection admins, if they havent logged in previously, you may need to do an ‘ensureuser’ here).
    foreach(SPUser user in web.SiteUsers)
    {
           // check if they are a site admin
           if(user.IsSiteAdmin)
           {
                       // Create a new task item
                       SPListItem myTask = list.Items.Add();
                      // Now we need to create an SPFieldUserValueCollection which stores a list of users for the ‘AssignedTo’ field.  We use this to allocate a user to the task.
                     SPFieldUserValueCollection fv = new SPFieldValueCollection();
                       // add the new user into the collection
                        fv.Add(new SPFieldUserValue(web, user.ID, user.Name));
                      // Assign the user to the task
                      myTask["AssignedTo"] = fv; // Note, you can use the enumeration here if you want for corefields
                     myTask["Title"] = ”Created ” + username;
                     // usually you would create a link to the /_layouts/people.aspx page here in the description too.
                     myTask["Description"] = string.format(”created user {0} with email {1}”, username, email);
                   // Finally update the task which adds it to the list and assigns the user…
                   myTask.Update();
           }
     }
}

 

Done :)

Now each administrator will get a new task created in the task list when a user registers via FBA to SharePoint.  I’ve used a SQL membership backend store, but you can use whatever you want – just utilize the ASP.NET login controls in a custom layout page, or however you want to manage the registration :)

There’s a few tricky things here that caught me out – one of them was the SPFieldUserValueCollection that you need to assign to the AssignedTo field – SharePoint uses this collection as a lookup, as a means to collect multiple users when assigning them to a task (if you look in the newform for the task, youll see you can add multiple users – all they are, is comma delimited strings being added (with an identifier) to this collection).  You then just shove that collection into the AssignedTo field.  NOTE:  When you assign it to the field and call Update(), it doesnt store a reference to the SPFieldUserValueCollection, it serialises it into a string, and stores a string representation of the collection into the field.  So if you come back again, and try cast it back to one of these, it will fail.  Instead, call the (web, string) constructior on the SPFieldUserValueCollection and pass it the string representation as the second argument, it will then deserialise it back into one of these collections for you :)

HTH,

Matt





Object reference not set to an instance of an object at asp._layouts_new_aspx.OnLoad(EventArgs e)

24 04 2009

If you’re getting the above mentioned error, and you’ve enabled forms authentication within SharePoint (I’ll mention SqlMembership here for google’s sake), then you’re getting this error because you havent enabled Client Integration within the authentication providers section of central administration!

Other quirks that you will witness if you do not turn this on include not being able to fill out forms services reports.  The ‘New’ button/drop down on your content type driven list will be empty, and all you will see is ‘New Folder’.

So what are you waiting for, turn ‘SharePoint Bollocks Quirks Mode’ off by turning Enable Client Integration on.

Lost a lot of time on this one, thanks Microsoft :)

Hope this helps some other poor soul.





InfoPath form template not editable – cant modify tables

23 04 2009

We had a massively bizzare issue this morning with one of our form templates.  We are currently building an InfoPath forms services + workflow solution, and a collegue of mine had copied one of our form templates to start a new form.

We are building the forms within Visual Studio.  The form template seemed to be in ‘Read Only’ mode.  At least – the default view was.  When we right clicked some of the tables everything was grayed out, it wouldnt let us insert new columns.  It would let us edit rules and such, though.  Very strange.

After disecting the form template manifest and view.xsl and seeing nothing obvious, I created a new view and copy-pasted the original view (the one that isnt working) into the new one.  I then used winmerge to compare the XSL generated for the new view to the old view.

This is what I found in the one that wasnt working:

<base href=”x-view://b724ca29177f40c8a/default.htm&#xA;”></base>
I have no idea what this actually implies, but when I removed it – the form template worked again.  Everything became editable in the view.  I guess it’s some type of reference that, when he copied the template, became invalid causing the view to ‘lock’.
:)   I love hacking.  Hope this helps someone else!
Matt




Migrating from Hyper-V to Virtual Server

17 04 2009

So you’ve just installed all of the hyper-v bits and peices on your VM, and you’ve started it up in hyper-v – it’s upgraded the HAL to the new Uniprocessor HAL, and everything is fine.

Whoops, now you need to run that VM in Virtual Server 2005 R2 SP1.

It’s totally unsupported by Microsoft, BUT YOU CAN DO IT.  I just spent the last hour or 2 fiddling around with it, and I finally got it right.  Here’s the steps:

1. Take a copy of the VHD file.

2. Create a new VM in hyper-v and attach the copy

3. Go to device manager, expand ‘computer’, double click on ACPI Uniprocessor, click on the ‘Driver’ tab, click  ’Upgrade Driver’.  Click  ‘Install from a list or specific location (Advanced)’, then click ‘Don’t Search.  I will choose the driver to install’. 

Select ‘Advanced Configuration and Power Interface (ACPI) PC’  and click next to install it, then reboot.

4. When rebooted, it will display a dialog box asking you to restart.  Say ‘No’, then go into add remove programs in windows and uninstall ‘Hyper-v guest components’.

5. Once this is done, you’ll notice device manager will have a whole heap of unrecognised devices, this means that it’s removed the HID, NIC , etc drivers. 

Reboot now, then once its booted, shut down the VM.  Copy the VHD to your virtual server machine, and attach it to a new VM – it should just work.  Once this is done, you can install the virtual server machine additions (but it seems to run quick without them).

So what have we done?  When hyper-v installs its guest components, and upgrades the HAL – it installs the uniprocessor hal.  This hal is incompatible with virtual server, so if you try boot it into virtual server like this it will just show a spike in the CPU, and then it will flat line and you will be staring at a black screen.

You need to change it back to the advanced ACPI HAL which is usable under virtual server, and remove the guest components.

I have had a situation during my tinkering which caused the input devices to totally fail, aka – it no longer can install some of the HID drivers so your keyboard doesnt work, or mouse – not sure how i fixed this, I think it was the order I did things.  Hopefully it will just work for you though, in the order i specified – LET ME KNOW!

 

All the best,

 

Matt





Victorian Bushfires

12 02 2009

I cannot stress how devistating this whole situation is.  If you have a dollar, and you have a heart, click here right now and donate:

https://www.redcross.org.au/Donations/onlineDonations.asp

No questions.  Just DO IT.





AvePoint DocAve – 2003 to 2007 migration fails with: Failed to process the browse request, the browse process timed out

12 02 2009

Whenever trying to expand the agent for the source migration, it kept timing out.  We also got the following errors:

–Erroring: id[3439_1234421027821] message[com.avepoint.docave.sp.service.ServiceException: Back end error:Failed to process the browse request, the browse process timed out.]
 
The second error, more detailed:
Method execution failed: com.avepoint.docave.sp.service.ServiceException: Back end error:Failed to process the browse request, the browse process timed out. at com.avepoint.docave.sp.service.impl.SPNodeServiceImpl.getNodesByType(SPNodeServiceImpl.java:451) at com.avepoint.docave.sp.service.impl.SPNodeServiceImpl.getNodes(SPNodeServiceImpl.java:329) at com.avepoint.docave.sp.dwr.SPRestorePlanDwr.get2007ItemLevelNodes(SPRestorePlanDwr.java:169) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34) at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:316) at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:319) at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:178) at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:130) at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:191) at javax.servlet.http.HttpServlet.service(HttpServlet.java:713) at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValvejava:230) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValvejava:175) at org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:56) at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:353) at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source)

We ended up fixing this problem by Changing the account used in the ‘Account Configuration’ section, within the ‘Control Panel’ for the problem agent.  We set up an account and gave it policy in sharepoint, and local admin – failed….  We changed it to use the original ‘administrator’ account, and it worked.

I don’t know exactly why this is failing, or under what circumstances you need access to a particular resource – however, I do know that you will fix it by giving it the highest privledged account you can.  Can someone from avepoint confirm EXACTLY what level of access this account needs?!?!?

HTH