I would like to customize the add new item form in a sharepoint list to pull a query string parameter and automatically set it as one of the lookup fields in the new item. I have found a perfect tutorial (http://www.codeproject.com/Articles/194253/How-to-Customize-the-New-Item-form-to-take-paramet) for how to do this in Sharepoint Designer 2010 in Sharepoint 2010 but design mode was removed Designer in 2013 so that tutorial is not of much use.
So basically what I'm asking is how do I do pull query string values in Sharepoint Designer 2013?
Best Solution
In addition to customizing List Views & Forms via XSLT, with SharePoint 2013 was introduced a Client Side Rendering (CSR) technique. As an introductory please follow this article Introduction to Client Side Rendering in SharePoint 2013.
Since CSR is the default rendering mode in SharePoint 2013, I would recommend this approach to customize a New Form page.
Solution
Suppose a Tasks list that contains a
Task Category
lookup field.Then the following rendering template could be used for setting
TaskCategory
lookup field value retrieved from a query string parameter namedcat
.Key points:
LookupId
GetUrlKeyValue
is a SharePoint specific function that serves for extracting parameter from a query stringHow to apply changes
In order to apply the changes we need to set the
JSLink
property of XLV web part:Tasks.js
. Then upload the specified into SharePointSite Assets
libraryMiscellaneous
groupJSLink
property and specify its value:~sitecollection/SiteAssets/Task.js
as shown on figure belowResult