Geeks With Blogs

News These postings are provided "AS IS" with no warranties, and confers no rights.
Locations of visitors to this page virtusa corp sharepoint virtusa.com shehan peruma
Shehan Peruma

 

Here’s the scenario:

The user navigates to the NewForm.aspx page of a list and enters values into the necessary fields. As soon as the user click the OK button the browser should take the user to the EditForm.aspx page and load the previously entered item in edit mode and also start the approval workflow on the item.

 

Solution:

Create a event receiver for the list that hooks up to the ItemAdding event. There are quite a few blog posts out there that talk about this, so instead of typing down the same you can check them out for yourself here and here (note: do read the comments too as there some useful tips in there as well).

Following the same/similar approach would help you meet your requirements. For the workflow bit; after adding the item use the sites workflow manager object to kick start the workflows associated with the list (see here for sample). Add yes that works. But here’s where the problem is, in my scenario the site from which users will interact with the list is an extended site that’s in the Internet zone and uses FBA authentication. The original web application uses NTLM and (obviously) has a different URL (host header). So when the workflow mail arrives it has the urls for the NTLM site.

To overcome this you would need to obtain a copy of the SPContext.Current object into a variable in the constructor of the event receiver (much like how you’re capturing the httpcontext object mentioned in the blog posts links above), then utilize this to retrieve the SPSite and SPWeb objects inside of the ItemAdding event handler instead of going through the properties (SPItemEventProperties) parameter.

By doing the above SharePoint knows which context to use when performing its operations and then adds the correct url to the workflow emails.

 

Posted on Friday, October 1, 2010 6:04 PM MOSS , WSS , Development | Back to top


Comments on this post: Staring a workflow inside a list event receiver sends out a wrong link

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © shehan | Powered by: GeeksWithBlogs.net