I’m trying to create a dynamic link on a form to a document stored in another document library and haven’t been able to figure it out yet.
On the form I have add a List Lookup control that is pointing to a document library with job description documents. When a user selects a document from the dropdown I want there to be a link on the form that they can click which will open the document in a new tab in the browser using the office web apps tool. This gives the user the ability to review the document that they’ve selected before submitting the form.
The hyperlink format would be as follows:
[Current Site Url]/_layouts/15/WopiFrame.aspx?sourcedoc=[Url of Selected Document]&action=default
Things I’ve tried:
- I tried adding a Label control to the form which allows you to create a hyperlink on the form but there is no way to reference a form variable, calculated control or use the lookup function to get the Url of the selected document. As a result I can’t see a way to reference the Url of currently selected document in the form dropdown.
- Next I tried using a calculated column to create a dynamic hyperlink based off the dropdown(Position in this case) as follows:
"<a href='" + Site URL + "/_layouts/15/WopiFrame.aspx?sourcedoc=" + lookup("Civilian Job Descriptions","Label",parseLookup(Position),"URL Path") + "&action=default' target='_blank'>View Job Description</a>")
This works fine when the form is in new/edit mode but when you open the form in display mode it will display the literal HTML tag (ie. <a href=’….)
Anyone have any other ideas on how to add a dynamic link on a form?