locked
How to retrive the Record GUID RRS feed

  • Question

  • Hello All,

    I want to know how can i get the GUID of account record which created using SOAP. Below is the code.

    function Create()
    {
    // Prepare values for the new contact.
    var firstname = Xrm.Page.getAttribute("firstname").getValue() + " - "  + Xrm.Page.getAttribute("lastname").getValue();
    var authenticationHeader = GenerateAuthenticationHeader();

    // Prepare the SOAP message.
    var xml = "<?xml version='1.0' encoding='utf-8'?>" +
    "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" +
    " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
    " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +
    authenticationHeader +
    "<soap:Body>" +
    "<Create xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" +
    "<entity xsi:type='account'>" +
    "<name>" + firstname + "</name>" +
    "</entity>" +
    "</Create>" +
    "</soap:Body>" +
    "</soap:Envelope>";
    // Prepare the xmlHttpObject and send the request.
    var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
    xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
    xHReq.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Create");
    xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xHReq.setRequestHeader("Content-Length", xml.length);
    xHReq.send(xml);
    // Capture the result
    var resultXml = xHReq.responseXML;

    //Update ParentCustomer in Contact Record

    // Check for errors.
    var errorCount = resultXml.selectNodes('//error').length;
    if (errorCount != 0) {
        var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
        alert(msg);
    }
    }

    Monday, December 17, 2012 6:53 AM

Answers

  • Hi,

    > Make sure you are not calling save function through code.

    > try to put one alert and check how many times that alert is comming.

    >you can also check by debugging your script that how many times it is called.


    Contact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Marked as answer by Kumar_R Monday, December 17, 2012 2:30 PM
    • Unmarked as answer by Kumar_R Monday, December 17, 2012 2:30 PM
    • Marked as answer by Kumar_R Monday, December 17, 2012 2:31 PM
    • Unmarked as answer by Kumar_R Monday, December 17, 2012 2:31 PM
    • Marked as answer by HIMBAPModerator Monday, December 17, 2012 3:53 PM
    Monday, December 17, 2012 9:34 AM
    Moderator
  • Hi,

    Thanks for your reply.

    Regards

    • Marked as answer by Kumar_R Monday, December 17, 2012 2:31 PM
    Monday, December 17, 2012 2:31 PM

All replies

  • Hi,

    you should get id like below

    var contactid = resultXml.selectSingleNode("//CreateResult");


    Contact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Monday, December 17, 2012 6:56 AM
    Moderator
  • Hello Mahender,

    Thanks for your reply. When i execute the above script, including business logic record, one more record(with name "Null") is getting creating. Can you help me what is the problem in code.

    Thanks

    Monday, December 17, 2012 7:20 AM
  • Hi Kumar,

    It seems you are making call to create function two times, could you share your complete code here for inquiry ??


    Contact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Monday, December 17, 2012 7:28 AM
    Moderator
  • I already placed the complete code. There is no additional changes.

    Thanks

    Monday, December 17, 2012 7:36 AM
  • Can you show where and how you are calling this function any screenshot ??

    Contact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Monday, December 17, 2012 8:02 AM
    Moderator
  • Hi,

    Attached the screenshot.

    Thanks

    Monday, December 17, 2012 9:26 AM
  • Hi,

    > Make sure you are not calling save function through code.

    > try to put one alert and check how many times that alert is comming.

    >you can also check by debugging your script that how many times it is called.


    Contact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Marked as answer by Kumar_R Monday, December 17, 2012 2:30 PM
    • Unmarked as answer by Kumar_R Monday, December 17, 2012 2:30 PM
    • Marked as answer by Kumar_R Monday, December 17, 2012 2:31 PM
    • Unmarked as answer by Kumar_R Monday, December 17, 2012 2:31 PM
    • Marked as answer by HIMBAPModerator Monday, December 17, 2012 3:53 PM
    Monday, December 17, 2012 9:34 AM
    Moderator
  • Hi,

    Thanks for your reply.

    Regards

    • Marked as answer by Kumar_R Monday, December 17, 2012 2:31 PM
    Monday, December 17, 2012 2:31 PM