0

Using REST, I am trying to create an item that has a lookup column named Role. In this column's settings I am referencing the Title field. I can create a new item using "RoleId" as shown below, however I would like to update the role to one of the available titles in the lookup list without the lookup ID.

var payload = JSON.stringify({
  __metadata: {
    'type': 'SP.Data.ZzzListItem'
  },
  Title: "Test",
  RoleId: 1
})

$.ajax({
  method: "POST",
  url: "https://mySite/_api/web/lists/getbytitle('zzz')/items",
  data: payload,
  contentType: "application/json;odata=verbose",
  headers: {
    "Accept": "application/json;odata=verbose",
  },
  success: function (data) {
    console.log("newly created item", data);
  },
  error: function (data) {
    console.log(data);
  }
});

How can I update the Role by just using a title represented in the lookup list rather than an ID?

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.