0

I would like to update a multiple lookup field in SharePoint Designer 2013. OOTB this is not possible. In SharePoint Designer 2010 it was possible. Now I would like to do this with for example a REST API call in the SharePoint Designer 2013 workflow. How can I do this?

UPDATE:

I've tried first to make it work in JavaScript but it is not working yet. What am I doing wrong in this script?

<script src="https://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script><script type="text/javascript">

$(document).ready(function(){

$.ajax({
    url: "<siteUrl>/_api/web/lists/getByTitle('TestKH')/items(5)",
    type: "POST",
    contentType: "application/json;odata=verbose",
    data: JSON.stringify({
         '__metadata': {
            'type': 'SP.Data.TestKHListItem',
         },
         'SBSId': { "results": [1,2] }
    }),
    headers: { 
          "Accept": "application/json;odata=verbose",
          "X-RequestDigest" : $("#__REQUESTDIGEST").val(),
          "X-HTTP-Method": "PATCH",
           "If-Match": "*"
       },   
    success: function (data) {
        console.log("done");
    },
    error: function (err) {
        console.log(JSON.stringify(err));
    }
});
});
</script>​​
1
  • Are you getting any error while using this code? – Ganesh Sanap Jan 11 at 16:22
0

Not sure how to make the API call in SP Designer (it's a hassle!) but your data should be something like this:

'ColumnNameId': {"results": [59, 60] } 

Note that you need to add 'Id' to the column name. The results object contains an array of the IDs of the lookup items.

0

You can make API calls via the "Call HTTP Web Service" action available in SharePoint 2013 workflows. More information can be found here:

Working with Web Services in SharePoint Workflows using SharePoint Designer 2013

0

Use below code to update lookup column with multiple selection:

<script src="https://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>

<script type="text/javascript">
    $(document).ready(function(){
        $.ajax({  
            url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('TestKH')/items(5)",  
            type: "POST",  
            headers: {  
                "accept": "application/json;odata=verbose",  
                "content-Type": "application/json;odata=verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val(),
                "IF-MATCH": "*",  
                "X-HTTP-Method": "MERGE"  
            },  
            data: JSON.stringify({
                    "__metadata": {
                        "type": "SP.Data.TestKHListItem",
                    },
                    "SBSId": { "results": [1,2] }
                }),    
            success: function(data) {  
                console.log("Updated successfully.");  
            },  
            error: function(error) {  
                console.log(JSON.stringify(error));  
            }  
        }); 
    });
</script>

Note: Make sure you are using correct internal name of your lookup column in data.

For designer workflow part you can follow below blogs:

  1. REST-API POST call using SharePoint designer workflow
  2. SharePoint Designer 2013 Workflows and POST REST API
1
  • @Jackson, have you tried it? is it working for you? – Ganesh Sanap Jan 20 at 9:48

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.