InfoPath– Formulate Email Link to Browser Form
When using InfoPath 2010 with SharePoint, it is common to create workflows to send a link to the form. The most common thing in my experience is an approval process. Each time the form needs to be approved, the next approver is sent an email via SharePoint Designer workflow. There is a “URL Path” field that can be used in the email, which will directly open the form. The problem with this method is that there is no way to control *how* the form is opened. If the end user has the InfoPath client software on their computer, clicking this link will open the form in InfoPath…. even if it is a browser based form and you want it to always be opened in the browser.
Why would you care if the form gets opened in the client or the browser?
- One main reason is to keep a consistent user experience. If they get a browser form every time they open the form, then they will be less likely to be confused about why the form looks a little bit different.
- Another, more obscure reason, is the timing issue with workflows. When I have a workflow that runs when a form is changed, sometimes if the client software is used, the software just isn’t quite finished closing when the workflow kicks off, so you get conflicts and errors. If the form is always opened in the browser, this will never happen.
Here’s how to formulate the URL. First, click an existing browser-based form, to dissect the URL. This is just an example of what the syntax will look like.
XmlLocation – This is the path to the the specific XML file, which is a form that has been filled out.
ClientInstalled – It says that the client is installed on my computer, but this parameter is not important in this situation.
Source – This is important. This is the URL where you want the person to be redirected to after they submit or close the form. By default it is the default view of the form library, but you can use any site in the site collection.
DefaultItemOpen – This tells it to open the form in the browser.
The Workflow Email Hyperlink
If you’re like me, you like to send a link to the form in several different emails, at different times in the workflow. For efficiency’s sake, I like to create the link as a workflow variable, so that it can simply be reused in several places. Here’s how:
- In your SharePoint Designer workflow, add a new action to “Set Workflow Variable” at the very beginning of the workflow.
- Click the blue text workflow variable, and choose Create a new variable. Name it FormLink, and make it a string. Click OK.
- Click the blue text value, and click the little … ellipses (string builder)
- Click the Add or Change Lookup button. Choose Workflow Context as the data source, and choose Current Site URL as the field. Click OK.
- After you select the Current Site URL, type the following text after it. (see screenshot) You are basically re-creating the same structure as that original URL that you copied.
- Put the cursor at the very end, and then use the Add or Change Lookup button again, this time selecting the Workflow Context and the Current ITEM URL (not current site again).
- Go ahead and recreate this entire string, as one big string with no spaces, there’s one more spot where you insert the “current site URL”. Click OK.
NOTE: In most situations, I want the end user to be redirected back to the home page after they submit or close the form, which is why I use “Current Site URL” in the &Source section. This is up to you, and can be some other site or page in your site collection.
- This is what the set variable action will look like:
- At any point in your workflow where emails are being sent, this variable can be used. In the body of your email, click Add or Change Lookup. Pick Workflow Variables and Parameters as your data source, and then pick the FormLink variable.
This method can be used in either list-based or reusable workflows. Stay tuned for more posts regarding hyperlinks in workflows and the task process designer.
Will you be covering the ability to display the link (InfoPath, List, Library or item) as an icon instead of string? New to this and not seeing where/how this could be accomplished. Keep up the terrific work, Laura!
Hi, i am very much new to share point. i have to program the list attachment(Resume to list attachment). i tried in google but no sample code found. can you help me? my id is email@example.com
You are awesome Laura!!!!! I used to do the hyperlink thing differently – but lately it breaks and I JUST CANT GET IT TO WORK!!! See below – would be interested if you knew what went wrong. It displays the hyperlink in the email but only once you ‘forward’ the mail and enter behind the link – does it become active (blue underlined). HOW: “Copy hyperlink of open browser doc. Replace name of document in string with the “name” of the document in the library by adding a Lookup to Body in the Email in SharePoint Designer. Delete the rest of the string. Add “&OpenIn=Browser” at the end of the string. This really used to work before??!!
MikeZ, Add a content editor web part to your home page, and then insert an image into it. Create this hyperlink on that image. I covered some of this kind of basic stuff in my InfoPath book also, if you’re interested. Sathish, There’s an attachment control in InfoPath, no code needed. Does that answer your question? Tracy, Do you mean a word document or infopath form? It worked before… before what? Have you tried the method in this blog post?
Hi Laura, Just wanted to say THANKS!!! I knew how to do this in MOSS 2007, but the process changed for SP2010. Your instructions worked perfectly! Thank you.
Hello Laura Thanks for the article. I have an issue where there are spaces in the site URL. The link that appears in the email is broken where the spaces are. Is there any way to replace spaces with %20 so that the link will work? Thanks again Matt
Thanks Laura, you rock. This saved me a lot of time and effort. One note: If the name of the form library contains a space, then the link is broken in the email with [%Workflow Context:Current Item URL%]. For some reason, spaces are not repalced with %20. I used [%Current Item:Encoded Absolute URL%] instead, and that worked.
Thanks DaveB, Matt, go ahead and try what Dave did.
Thanks Laura for your usual post. Please concerning this Formulate Email Link to Browser Form, i want to have a second link for people accessing the form over the internet. We just published our sharepoint (local address:hqportal) on the internet with ISA(internet address: webportal), we can fill a form from the internet but the Formulated Email Link to Browser Form is showing the (local address:hqportal) i need the link to have the address of the external address.
You’ll have to just hard code the actual http://… URL straight to your site, instead of using the workflow context.
Hi Laura, would you be able to explain how to do this for SharePoint 2007 please?
Thanks in advance.
I am having the same problem as Dave, my url has spaces in it so it is not working. I do not see the “EnclodedAbsoluteURL” when i insert Content I just see some fields in my form.
If I try to manually type it .. It goes away when I save.
My document folder is Vendor Forms(so there is a space)
and the docs have spaces as well)
Hmm, in the workflow when you pick from the current library’s list of fields, I’ve never seen encodedabsoluteURL not be in there, so I’m not sure where else to tell you to look. Is it a reusable workflow or just based off the library?
Hello- Your For 2007 link was not recongized by my browser?
Hi Laura, great site. In SP 2010 I have made a copy of the standard approval workflow and followed your steps. When I’m assigning the approver names in the create workflow form I select the name using the people picker but then get a “Cannot submit form error”. Any idea what the problem could be?
Thank you for your great techs. I followed your instruction to create the hyperlink successfully. But it came out to be an intranet server path:
http://shp01/sites/…. (shp01 is my server name)
What’s I want is a internet URL.
My MOSS is configured with the above internet URL and it works fine.
I am very confused bout this! Would you please advise me on this? Thank you in advance!
Do you get that error for every form you build, or just ones with a people picker in them? What are you using for the “file name” in your data connection?
Sounds like something is wrong with your DNS or some setup on your server. Sorry but that is not my area of expertise. @ToddKlindt may know (ask on twitter)
Awesome post! It works like a charm! But…(isn’t there always a “but”!)…
I have code in my form to add the query for the user’s name when they approve something in my form. This works when they open the form from the SP library. However, when they open the form from the link in the email, they get an error. I presume (since it works when I take it out) that it doesn’t have a username() when it comes from the email??? Thoughts? Suggestions? HELP!
With custom code, you never know. I’ve never used code in a form, so I’m not sure what it could be doing. I’ve never seen it simply not have username() info. Also, I’m not sure why you’d need custom code because stuff like that can all be done out of box. Is UserName() still there when you remove the custom code?
I have been using these instructions to create links in 2010 for quite some time and it works great, but I am now trying to do this in 2013 and the URL is not working. Is there a new set of steps for 2013?
I actually figured this out – here is the URL format that I have used in 2010:
[%Workflow Context:Current Site URL%]/_layouts/FormServer.aspx?XmlLocation=[%Workflow Context:Current Item URL%]&Source=[%Workflow Context:Current Site URL%]&DefaultItemOpen=1
and by comparing URLs, I found that I was missing the “/” before the Current Item URL in 2013. So I added one to the string where it was missing:
[%Workflow Context:Current Site URL%]/_layouts/FormServer.aspx?XmlLocation=/[%Workflow Context:Current Item URL%]&Source=[%Workflow Context:Current Site URL%]&DefaultItemOpen=1
and it is now working.
Awesome Carole, I’m glad you got it figured out!
Laura, I’m sure you hear this all the time, but you can’t possibly know how many times one of your videos or articles has saved me untold hours, days or weeks of trouble. THANK YOU SO MUCH. You’re brilliant!
Awesome, that’s great to hear!
I’m using this link, but is not working for me
Thank you, thank you, thank you. This worked soooooo…..well. I’ve been trying to do this for days!!!!! Got my life back. Great job Laura.
oops, I just realized that it is working and it is going to the default form view, however, I have rules on the form load to change views but it doesn’t seem to be working. Would you happen to know how I can go to a different view of the form using the URL?
You can’t, unless it’s a new form, not editing an existing one.
I got the form load rules to change views to work.
Can you point me to how it works on a new form?
If I made a new form from the old, would that work? Or must there be a new list, new fields, new everything?
Your book on InfoPath 2010 and Sharepoint 2010 has been like a bible for me. I built a fantastic form using the instructions in your book, and impressed all of my management! In the latest iteration, I was forced to change it from a browser-enabled to filler form (due to needing to use a multi-select list box). Unfortunately, this has had a negative ripple effect. One of the negative outcomes was that your instructions for creating a hyperlink in Sharepoint Designer only work for browser-enabled forms, which I now do not have! 🙁
I have figured out a way to open the item using 2 clicks (once in the email and once in Sharepoint), but I would love to have one click in the email open the form in Infopath. This is my FormLink variable definition in SPD: LINK TO FORM
It opens the current item in the form library, and there is a hyperlink to open the form in InfoPath, but it is 2 clicks, and as I said, I’d love to have it be one click. I am not confident the average user will understand they need to click again to open the form. I can put additional instructions in the email, of course, but would prefer not to!
You’d need to get a link directly to that XML file of that form. Then if a user has InfoPath installed on their computer, clicking that link should open the form.
Oops, Laura, I didn’t realize it was going to turn my text into a semi-functional URL. Let me try this again: ‘a href=”http://site/subsite/Forms/DispForm.aspx?ID=[%Current Item:ID%]”>LINK TO FORM‘
What is the equivalent link to the InfoPath form in Office 365 SharePoint Online? Thank you.
It’s the same.
Pingback: Email Hyperlink to Form | @WonderLaura