0

On one of my create forms I have a select-list that is populated with values from another list.

Now, when the user selects an option from the select-list and saves.. My goal is to change the status of the selected option in the original list. Now, 'Status' is a column that is a choice column and it has 3 options (Active, Deactivated, Assigned). When the user saves the form, I want to change the value of the 'Status' to Assigned.

Here is what I have:

var listItemData = {
    "Status" : "Assigned"
};

var requestHeaders = {
    'X-RequestDigest': $("#__REQUESTDIGEST").val(),
    "accept": "application/json;odata=verbose",
    "content-type": "application/json;odata=verbose",
    "IF-MATCH": "*",
    "X-HTTP-Method":"MERGE"
};

// Second ajax call - 'post', once the serial number has been proven to exist, will get that item and change the status to 'Assigned'
$.ajax({
    url: siteurl + "/_api/web/lists/getbytitle('SerialNumber')/items(" + itemId + ")",
    method: "PATCH",
    data: JSON.stringify(listItemData),
    headers: requestHeaders,
    success: function(data, textStatus, xhr){
        alert('Success');
    },
    error: function(error){
        alert("Error " + JSON.stringify(error));
    }
});

When this runs, I am receiving a run-time error:

enter image description here

Any idea as to how I can get this to work?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.