Update a list item using REST API in Rich Forms or Action Links

Document created by Matthias_Walter Employee on Dec 19, 2017
Version 1Show Document
  • View in full screen mode

You can use an "Execute Script" Action in skybow action links or skybow rich forms whether on a button or as a Form Load Action to call the SharePoint REST API (or any other REST service).

To update a list item use the following example.

 

Example Script:

var data = {
__metadata: { 'type': 'SP.Data.ContactsListItem' },
Title: 'updated Title2',
Total: 102
};
jQuery.ajax({
url: [[@Web.Url]]+"/_api/web/lists/getbytitle('Contacts')/items(1)",
method: "PATCH",
data: JSON.stringify(data),
headers: { "Accept": "application/json; odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"If-Match": "*"
},
success: function (data) {
  alert('Item added successfully');
},
error: function (error) {
  alert("Error: "+ JSON.stringify(error));
}
});

 

Find other examples to Get / Add or delete specific list items here:

https://social.technet.microsoft.com/wiki/contents/articles/31995.sharepoint-2013-working-with-rest-api-using-jquery-aja… 

 

Another option would be to use the "Update List Item" action which is very powerful and can be configured very easily and dynamic using the expression language

Attachments

    Outcomes