Tag : newifs.aspx

InfoPath – Link to a list item from a URL

It is possible to open another list item directly from the form in another window. This can be useful when you wish to link to related items in another list or add another list item. This is done by building a URL that points to the list that you wish to link to. While the building of the URL can be performed directly in the Hyperlink Data Source, I have found that it is clearer to build the link in a field and then tie the Data source directly to the field.

Add a text field to contain the URL

Add a text field to the form, in the example below I added the field ‘URLAttachment’. Note that the checkbox ‘Refresh value when formula is recalculated’ is checked

ip0812

Using the fx button,set the default value to one of the following

To open the window in ‘Insert/Add’ mode:

concat(SharePointSiteUrl(), “Lists/<List Name>/item/newifs.aspx”)

ip0814

Ultimately, the concatenation statement would yield something similar to:

https://contosa.sharepoint.com/sites/DEV/capex/Lists/Capex%20Documents/item/newifs.aspx

To open the window in Edit mode (ID = the ID of the item you wish to open):

concat(SharePointSiteUrl(), “<List Name>/Forms/EditForm.aspx?ID=235”)

ip0813

Ultimately, the concatenation statement would yield something like

https://contosa.sharepoint.com/sites/DEV/capex/Capex/Forms/EditForm.aspx?ID=235

If you are using an InfoPath form, the concatenation is different since you must open the XML document:

concat(SharePointSiteUrl(), “_layouts/15/FormServer.aspx?XmlLocation=”, substring-after(SharePointListUrl(), “.com”), <FileName>, “.xml&ClientInstalled=true&DefaultItemOpen=1&Source=”, SharePointSiteUrl(), “SitePages/CloseWindow.aspx”)

where <FileName> is the name of the XML file without the .xml extension (you may have to store this value in a variable in your form – mine is shown as File_x0020_Name[ID = OriginalCapex] in the figure below).

ip0811

NB. The code from ‘&Source=’ onwards is optional and is used to close the window automaticallt when the form is closed (See InfoPath – Close window automatically). Ultimately, the concatentation would yield something like

https://contosa.sharepoint.com/sites/JAH-DEV/capex/_layouts/15/FormServer.aspx?XmlLocation=/sites/DEV/capex/Capex/C16081611166332.xml&ClientInstalled=true&DefaultItemOpen=1&Source=https://contosa.sharepoint.com/sites/DEV/capex/SitePages/CloseWindow.aspx

Create a hyperlink in your form

Enter the text that you want the user to see for the prompt (For example: Click here to add an attachment) into a cell as follows

108-5

Tie the hyperlink’s ‘Link To Data Source’ to the created field

Highlight the line you typed in the previous step, right click and select ‘Hyperlink …’. A dialog box will open up. In the ‘Link To’ section, click on the radio-set option ‘Data source’ and then click on the Field Selector button to open up the Field Selection Dialog Box. From this box, select the field that you created in the first step above. Click ‘OK’ to save your settings

108-5

Publish the form

The link will now appear as a hypertext as shown below. Publish the form and whenever the hyperlinked text is selected, a new window will open with either the New or Edit form displayed

108-6

Notes on the above

  1. If your list has spaces in the name, you need to substitute ‘%20’ for each space
  2. This document was originally defined in MS/Word which sometimes changes the character representation when the font changes. To make sure that the quotation marks don’t change (as I have found they often do), make sure to replace any quotation marks copied from this document with new quotation marks
  3. It may be possible to use a similar URL structure in emails to allow the user to click the hyperlink directly from within the email, but I have come across some issues with buttons being enabled and you may have to use a different URL within emails