Showing posts with label InfoPath. Show all posts
Showing posts with label InfoPath. Show all posts

Tuesday, October 5, 2010

Using InfoPath and SharePoint Workflow: Create a task link to open the form in the browser.


One of the options that developers have while working with SharePoint is to use InfoPath forms and custom workflows. Another advantage is the ability to use InfoPath to integrate with SharePoint to provide a riche web forms that can be configured to enhance the user’s experience by setting default values and using filtering and views. The challenge in this scenario is not in the ability of handling the forms on the server (which is managed by the SharePoint when using web enabled forms) but with how the user who does not have InfoPath client installed interacts with the task e-mails sent for the workflow tasks. For example, look at the first link in the e-mail and you will quickly notice that it has an .xml extension.

If a user clicks on the link, the form will be downloaded and if the user does not have InfoPath installed on the machine, then the user will not be able to review the document.

In the following text, I will provide a very simple solution to this problem so that the user is presented with a link that opens the form on the server directly.

Here are the general steps involved:

1- We will create a custom task list to separate any tasks created by the work flow from other site tasks.
2- Go to the custom task list you created in step 1 and disable the custom task sending the e-mail
List settings --> Advanced settings then under E-Mail Notification

3- Select No for send e-mail when ownership is assigned?
 

4- Create a workflow that sends the e-mail notification for the form.
Below is a sample workflow I created for this demo:
The first action in the workflow is to create a variable to the URL of the form. To do this, select set workflow variable from the Actions menu.

5- On the variable name, select create a new variable and give it a name, in this case I named the variable FormURL.
6- In the value part of the action, click the Formula button and set the values of the look up as shown below:
Data Source: Form Library (the name of your form library)
Field from source: Encoded Absolute URL

In the “Find List Item” Section of the look up, select:
For the field: ID
Value: click the Formula button, and then set the values to:
Data Source: current item.
Form From Source: Workflow Item ID.

What we have done in this look up is to get the absolute URL for the item in the form library by whose ID matches the custom task list that has the matching Item ID.
The lookup should look like the figure below:

To explain this, when a task is created in a task list, the workflow adds 3 fields to the task
Workflow Item ID (the ID of the item that the workflow was initiated from- in this case the form item)
Workflow List ID (the ID of the List where you can find the item that the workflow was initiated from
-in this case the form library)
Workflow name: The name of the workflow that created the task in the task list

7- Once you have set up the variable as shown in the figure, you have the URL of the specific item you need.
8- Next, add send e-mail action (do not configure it now, we will configure it later)
9- Now open a form from your form library and copy the URL from the browser address
The URL will look like this:

10-Now remove the section in red (between location=) and (source) and add
Name of document to create a hyperlink using the document name.
11- And add [Document URL look up] instead. The code should look like the lines below:

12- Now, go to the send e-mail action that you created before and select it (do not double click to open it)
13- Once it is selected, go to the ribbon and select advanced properties

14-Select the body by clicking the button as shown below

15-Paste the code from the note pad
16-Replace the [Document URL look up] by selecting the text then click the ADD or Change Lookup button.
17-In the Lookup, select Workflow variables and parameters as the data source and the FromURL variable you created earlier.
18-Now the final step here is to replace the Name of document with a look up to the document name as follows:

Data Source: Form Library (the name of your form library)
Field from source: Name
In the “Find List Item” Section of the look up, select:
For the field: ID
Value: click the Formula button, and then set the values to:
Data Source: current item.
Form From Source: Workflow Item ID.

As you noticed, the setup is the same as the first look up but this time we selected the Name from the Form Library.

19-Now, set up your workflow to start automatically when Item is created.

You can customize your e-mail further and add company logo or any other html formatting that you need.





Thursday, March 11, 2010

Publishing InfoPath Form to SharePoint Server - URL not valid

I was trying to publish some Infopath forms this week and I got an error “ the following URL is not valid” I searched for info trying to figure out the reason for the issue and there were many different solutions to the problem. Here is a list of what I found from different sites – None worked for me:

1- http://sharepointcoding.wordpress.com/tag/infopath/
I already have a site at the root so that was not the solution for me.
2- http://littletalk.wordpress.com/2008/04/24/publishing-infopath-to-sharepoint-the-following-url-is-not-valid-error/
Same as above.
3- http://www.sharepoint-tips.com/2007/02/publishing-infopath-to-sharepoint.html

Although Ishai is suggesting that you should stop the Event Notification service on the server before you publish then re-start it again as soon as you finish publishing, I did not want to stop the service. This is because the service is running on a production server and there are other related services that require the System Event Notification service to be running.




What resolved the solution in this case is the following method:

By comparing two servers, the non-working site had this missing host header line item. The
X-Powered-By: ASP.net
was there in both site but the non-working site was missing the
MicrosoftSharePointTeamServices: 12.0.0.xxxx (depending on the service pack version)
By comparing the other sites on the non-working server I was able to get the correct value for the service pack in my case it was 12.0.0.6219.













Now the server is fixed but the client machine still needs to update a few keys in the registry so that it can find the server. To do this, regedit.exe and find the key: HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\Internet\Server Cache\
Delete entries for nonworking site (they are in this format
http://theNon-WorkingSiteName)
(You can also Version DWORD to c (12) but it is better to delete all the keys so that the next time you connect, these keys will be updated)