Sharepoint / Sharepoint Desginer / InfoPath: Create a dynamic link that opens a particular InfoPath view in a SharePoint dialogue box with it’s own edit icon

I found that I needed to have 2 views in SharePoint that both had an Edit Icon but each icon need to point to a different InfoPath view. I wanted the item to pop up in the dialogue box just like the normal edit icon did.  I took a look at how SharePoint was encoding theirs and was able to mimic it. Below you will find the solution.

The first part of this solution requires us to trick SharePoint into allowing the use of a Multiple Line of Text field in a Calculated column. We need to do this because the URL string you will be using is way over the 255 character limit of a single line of text field and SharePoint will not let you just add a Multiple Line of Text field to Calculated column.

1. Create a single line of text field (I called mine “Link Holder“).

2. Create a Calculated column (I named mine Edit Item)
– Add the Single Line of Text field (Link Holder)  to the Formula
– Set the data type as Number (for some reason this is the only way to make it read as html)
– Click Ok

3. In SharePoint Designer make a workflow that puts together the html you would like using the Set Field to value action.

Ex. Set Link Holder to <a href=”[Encoded Absolute URL]/../Item/editifs.aspx?DefaultView=ViewName&amp;ID=[ID]” onclick=”EditItemWithCheckoutAlert(event, ‘[Encoded Absolute URL]/../Item/editifs.aspx?DefaultView=ViewName&amp;ID=[ID]‘, ‘0’, ”, ”, ‘1’);return false;” target=”_self”><img border=”0″ alt=”Edit” src=”/_layouts/images/edititem.gif”></a>

In the above example I am pulling the main part of the url from the Encoded Absolute URL field and also the current item’s ID. Notice that this happens twice. I have inserted the name of my view where it says ViewName. Please note that the view name is case sensitive.

Once you publish this workflow and run it on your item you will see the edit icon shows up in your Calculated Column field and, when clicked, it opens a dialogue to the correct View of your InfoPath form.

 

This entry was posted in InfoPath, SharePoint, SharePoint Designer and tagged , , , . Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Your email address will not be published. Required fields are marked *