How to create a list with different dropdown values and auto populate one of them on different sites? Check it out now.
First create a list on an site of your choice.
Click “Site Contents” and then “add an app”.
Create a “Custom List” (1) and set a “Name” (2). Then click on “Create” (3).
Next open the list and create a column. In the window, type in a column name (in the post I will explain this for the column “Team”).
Select the “Choice (menu to choose from)” and set a few values. After that select “Drop Down Menu” and delete the value in “Default value”.
Now create an item and open up the developer tools (F12). Select the drop down menu and you will find your control id.
This step is important, because you will need this id later in this guide. Your id is probably a different one.
Edit the NewForm.aspx and add a Content Editor to you site.
Click now on “Click here to add new content”.
Paste the following script and replace it with your drop down control id.
document.getElementById("Your Dropdown Control ID").value = getParameterByName('Team');
window.onload = myFunction;
var url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results) return '';
return decodeURIComponent(results.replace(/\+/g, " "));
Save the script by clicking “OK”.
After that click in the ribbon on “Page” and then “Stop Editing”.
As an alternative you can add the script via the JS-Link option. Therefore click on “Edit Web Part”.
On the right side under “Miscellaneous” type in your JS-Link. You can find another guide in my blog here: Upload .js files and link it to lists in 9 Steps (de / en)
Now you can open you NewForm.aspx with the parameter “?Team=<DropDownValue>” and the value is automatically set. Awesome!
With that you can create e.G. a button wherever you want and can preset the column of you choice.
The user has now less typing / selecting and the error rate will decrease.
You can do that on your site e.G. like this:
If you like this blog post I would appreciate if you share this post in your social networks.
You can also follow me on Twitter or Facebook to get always the newest information.
Do you want to see a YouTube-Channel? Let me know via E-Mail, Comment, Facebook or Twitter.