I am stuck at a place where I have to update a list which has a Lookup column. For example I am using this code to update my normal list
var clientContext = SP.ClientContext.get_current();
var webSite = clientContext.get_web();
var lists = webSite.get_lists();
var testList = lists.getByTitle("TestList");
var itemCreationInfo = new SP.ListItemCreationInformation();
var listItem = testList.addItem(itemCreationInfo);
listItem.set_item("Title", "ABC");
listItem.set_item("Name", "XYZ");
listItem.set_item("Age", 21);
listItem.update();
clientContext.executeQueryAsync(Function.createDelegate(this,this.Succeeded),Function.createDelegate(this,this.Failed));
Now, I have to update another list with the ID of the just created item in the TestList, as a lookup column. On Succeeded function again I am trying to update the second List,
function Succeeded(sender,args)
{
....
....
var carsList = lists.getByTitle("LookupList");
var itemCreationInfo = new SP.ListItemCreationInformation();
var listItem = carsList.addItem(itemCreationInfo);
listItem.set_item("Title", "Plan");
listItem.set_item("Place", "Delhi");
listItem.set_item("PlanId", ***???*** ); // Lookup Column
listItem.update();
But how can I get recently added item id to provide in PlanId column at Succeeded function. Please let me know what needs to be done for the same.