Setting a lookup column’s default value in SharePoint Online

For a recent project I needed a lookup column that was hidden and defaulted to a specific list item. On premise this is simple to achieve:

  • Use SharePoint Manager 2013 to set the default value, format of the value needs to be ID;#Title e.g. 1;#Details
  • Set the lookup column to hidden within the site content type – This is a must, otherwise the UI will override the default value

For SharePoint Online I decided to use SharePoint’s REST API to set the lookup column’s default value. To save anyone else from spending time on something that should be simple I’ve created a simple tool for updating the default value of site columns:


  1. Copy and paste the code in this post into a script editor web part
  2. Enter the display name of the (site) lookup column into the Column Name field
  3. Enter the ID of the list item that the lookup column should default to within the Default Value field
  4. Click Update Column
  5. Check the result by modifying the following rest call to match your site and column, then paste it into the address bar – https://Your Site/_api/web/fields/getbytitle(‘Your Column‘)/defaultvalue

The tool will use Sharepoint’s  status bar to provide the outcome, as shown below:


<script src="//"></script>
<script type="text/javascript">
var statusId = '';
var notifyId = '';
function updateColumn(){
	var colName = document.getElementById("siteColumn").value;
	var defaultValue = document.getElementById("defaultValue").value;
	var webUrl = _spPageContextInfo.webAbsoluteUrl
	if (colName.length == 0 || defaultValue.length == 0){
    	statusId = SP.UI.Status.addStatus("Ensure you have populated both the Column Name & Default values then try again");
    	SP.UI.Status.setStatusPriColor(statusId, 'red');
  		url: webUrl + "/_api/web/fields/getbytitle('" + colName +"')",
  		type: "POST",
  		data: JSON.stringify({
            "__metadata": { type: "SP.Field" },
            DefaultValue: defaultValue
          headers: { 
    		"X-RequestDigest": jQuery("#__REQUESTDIGEST").val(),
    		"content-type": "application/json;odata=verbose",
    		"X-HTTP-Method": "MERGE"
  		success: successHandler,
  		error: errorHandler
		function successHandler(){
		statusId = SP.UI.Status.addStatus("Yep we worked");
    	SP.UI.Status.setStatusPriColor(statusId, 'green');
		function errorHandler(error){
		statusId = SP.UI.Status.addStatus("Failed - " + error.statusText);
    	SP.UI.Status.setStatusPriColor(statusId, 'red');
<table cellpadding="5">
<th>Column Name (Display Name)</th><th>Default Value</th>
<tr><td><input id="siteColumn" ></td><td><input id="defaultValue" ></td></tr>
<tr><td><input style="margin-left:0px;" id="goButton" type="button" value="Update Column" onclick="javascript:updateColumn();"></td><td></td></tr>

2 thoughts on “Setting a lookup column’s default value in SharePoint Online

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s