Using JSOM, I getting all the task details which are not started. Using CAML query i got all the column values including related item column from Task list

var relateditm = $(this).attr("ows_RelatedItems");

The value i got is


I want the Item ID alone. How can i retrieve the id from this?

I tried with the below code, but undefined error is coming

var relateditmid = relateditm[0].ItemId;

1 Answer 1


Base on your code, the value you get is a string not an object.

so the code : var relateditmid = relateditm[0].ItemId; will return the item ID after converting the string relateditm to Object using eval funtion.

var relateditmObj = eval(relateditm);
var relateditmid = relateditmObj[0].ItemId;
  • Thank you. It is working. If my question is useful. Vote UP :) May 18, 2016 at 7:36
  • Not a big fan of eval. I would use JSON as the result you are receiving has JSON formatting: var relatedItem = JSON.parse(relateditm); var itemID = relatedItem[0].ItemId
    – Suleyman
    May 18, 2016 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.