You need to sign in to do that
Don't have an account?
How to get id from Create response
I am sort of posting this question twice - my apologies. I have done a bit more research and think I am on the right track but have hit a wall.
I am trying to obtain the key of a new opportunity created by my sforce control.. The code I am using was initially posted by DevAngel and demonstrated how to calculate a field and perform an update using javascript and msxml. I have modified the code to do clone operation from an existing opp.
The problem is that I can't seem to get to the id that is returned in the response from the create call per the API. I can see the key when I display the msxml.responseText. For some reason the selectNodes isn't working because objNodeList is undefined.
Here is the code I am using to attempt to retrieve the "id" node that is returned per the API doc. Any guidance would be greatly appreciated.
if (status == 200)
{
xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmlDoc.loadXML(msxml.responseText);
xmlDoc.setProperty("SelectionNamespaces", "xmlns:sf='urn:sobject.enterprise.soap.sforce.com'");
var objNodeList = xmlDoc.documentElement.selectNodes("//sf:id");
var newoppid = objNodeList.item(0).text;
document.write("<br><strong><center>Opportunity successfully cloned.");
//window.parent.parent.location.href="https://na1.salesforce.com/" + newoppid;
xmlDoc.setProperty("SelectionNamespaces", "xmlns:sf='urn:sobject.enterprise.soap.sforce.com'");
to
xmlDoc.setProperty("SelectionNamespaces", "xmlns:sf='urn:enterprise.soap.sforce.com'");