Auto populate list column (en)


Auto populate list column en title

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”.

Auto-populate-list-column-en-1

Create a “Custom List” (1) and set a “Name” (2). Then click on “Create” (3).

Auto-populate-list-column-en-2

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”.

Auto-populate-list-column-en-3

Now create an item and open up the developer tools (F12). Select the drop down menu and you will find your control id.

id=Team_004a7466-0fe9-4e46-9449-0dea66785ee0_$DropDownChoice

Auto-populate-list-column-en-4

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.

Auto-populate-list-column-en-5

Click now on “Click here to add new content”.

Auto-populate-list-column-en-6

Paste the following script and replace it with your drop down control id.

<script>
	function myFunction()
	{
		document.getElementById("Your Dropdown Control ID").value = getParameterByName('Team');
	}
	window.onload = myFunction;

	function getParameterByName(name)
	{
		var url = window.location.href;
		name = name.replace(/[\[\]]/g, "\\$&");
		var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
		results = regex.exec(url);
		
		if (!results) return null;
		if (!results[2]) return '';
		return decodeURIComponent(results[2].replace(/\+/g, " "));
	}
</script>

Save the script by clicking “OK”.

Auto-populate-list-column-en-7

After that click in the ribbon on “Page” and then “Stop Editing”.

Auto-populate-list-column-en-8

As an alternative you can add the script via the JS-Link option. Therefore click on “Edit Web Part”.

Auto-populate-list-column-en-9

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)

Auto-populate-list-column-en-10

Now you can open you NewForm.aspx with the parameter “?Team=<DropDownValue>” and the value is automatically set. Awesome!

Auto-populate-list-column-en-11

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:

Auto-populate-list-column-en-12

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.

8 responses to “Auto populate list column (en)”

  1. That is a good tip particularly to those fresh
    to the blogosphere. Brief but very accurate information� Maany thanks
    for sharing this one. A must resd post!

  2. Great post. I was checkinng constantly this
    blog and I am impressed! Very helpful information particularly
    the last part 🙂 I care for such info a lot. I was seerking this particular information for a
    very long time. Thank you and good luck.

  3. May I simply say what a comfort to discover someone who truly understands what they’re talking about on the internet.
    You actually understand how to bring a problem to light and make it
    important. More people must read this and understand this side of the story.

    It’s surprising you’re not more popular since you most certainly possess
    the gift.

  4. Howdy! I simply would like to give you a big thujbs up for
    the exellent info you have got here on this post. I will be returning
    too your site for more soon.

  5. Hello There. I found your blog using msn. This is a really well written article.

    I will be sure tto bookmark it and come back to rerad more
    of your useful information. Thanks for the post. I will certainly comeback.

Leave a Reply

Your email address will not be published. Required fields are marked *