Question

Let's say I have a list with three fields:

  1. Title
  2. Description
  3. Type (dropdown)

Via the URL, would it be possible to set the value one of the fields?

for example,

https://.sharepoint.com/Lists/Test/NewForm.aspx?title=SetTheTitle

and it sets the value of the Title field to "SetTheTitle"? I know this could be accomplished with JS, but is there a built-in way?

Was it helpful?

Solution

You can use the URL to filter items that have been created. You can also set a query string parameter for different uses like retrieving it to hide or show different fields (i.e. ?Department=HR) and setting fields.

So, given that, you could set a field to a value if the query string equals a certain value.

This can be accomplished (as an example), by using the JSRequest object.

Given your URL https://.sharepoint.com/Lists/Test/NewForm.aspx?title=SetTheTitle, you could use:

JSRequest.EnsureSetup();

var queryString = JSRequest.QueryString["SetTheTitle"]; // queryString = "SetTheTitle"

Then

if (queryString === "SetTheTitle") {
    $(#MyFieldToSet).val("The query string set this field");
}

Something along those lines...

As far as I know, there is no way to set the value of a field from the URL only, as you would need a mechanism to do so, like REST, CSOM, etc.

I hope that makes sense.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top