0

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?

1

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.

  • Not the answer I was hoping for, but needless to say it answers my question. If I use custom js on the page, it defaults to the classic layout, which I am hoping to avoid. The requestor doesn't want a dropdown, so I was hoping to have 3 links on a page that forces the drop-down (or text field) to be set. But I really don't want to force it to the classic layout. Thanks for your help! – alexander7567 Nov 20 '17 at 15:57
  • 1
    Can you elaborate a little on "If I use custom js on the page, it defaults to the classic layout, which I am hoping to avoid."? Are you using O365 and SharePoint 2013? If you get a little creative, there might be a workaround. Possibly with other hidden fields and workflow? – dubSquaredCO Nov 20 '17 at 21:55
  • 1
    Also, what data or criteria are you using to set the value of the title field? Are they static titles or dynamic (i.e. based on another field on the form)? Depending on the answer, calculated columns could be a solution as well. – dubSquaredCO Nov 20 '17 at 22:03
  • Its in O365. If you use any custom code on a custom list, it won't use the modern layout anymore. It will only use the classic layout until you take out the custom code. – alexander7567 Nov 21 '17 at 1:51
  • So as sad as it is to say, the real problem is a manager wants me to create 3 lists. All with exactly the same questions. The only difference is the title. I suggested instead of doing that, make one list with a drop down with the three titles. It was stated that they didn't want to do this because their users have trouble selecting the right dropdowns. So she wants it to be 3 separate lists thus 3 separate links. I wanted to have the dropdown selected by having 3 different URLs. The list would auto select the dropdown or autofill the field with the correct option according to what link – alexander7567 Nov 21 '17 at 1:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.