locked
Assign form values after web service returns xml details. RRS feed

Answers

  • For the name element I'd use:

     

    var name = xmlDoc.getElementsByTagName("name")[0].text;

     

    And for currency:

     

    var currencylabel = xmlDoc.getElementsByTagName("transactioncurrencyid")[0].getAttribute('name');

     

    If these don't work I'd check if getElementsByTagName("name") returns anything. I don't think it is affected by xml namespaces, but that might be a problem

     

    Sunday, January 27, 2008 2:15 PM
    Moderator

All replies

  • Michael,

     

    Change your code to:

    Code Snippet
    alert(technology);

     

     

     

    not the alert("technology");

     

    Cheers,

    Jim

    Saturday, January 26, 2008 10:47 AM
    Moderator
  • Javascript is case sensitive, use alert(technology); instead of alert("technology");

     

    let me know if still any problem

     

    REgards,

    Imran

     

    http://microsoftcrm3.blogspot.com

     

     

    Saturday, January 26, 2008 11:04 AM
    Moderator
  • Hey Imran,

     

    Thanks for the response I'll fix the typo but that's not where the script errors out. 

     

    It's on the

     

    xmlDoc.loadXML(xmlHttpRequest.responseXML);

     

    That seems to raise the error.

     

    "There was an error with the fields customized event"

    customerid / onchange / type/mismatch.

     

     

     

    Saturday, January 26, 2008 1:49 PM
  • You shouldn't need to do this. The responseXML property is an Xml Document type, whereas the loadXML method is used to load a string. The following code should work:

     

    xmlDoc = xmlHttpRequest.responseXML;

     

    This should replace the following:

     

    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async=false;

     

    // Problem here ...

    xmlDoc.loadXML(xmlHttpRequest.responseXML);

     

     

    Saturday, January 26, 2008 5:44 PM
    Moderator
  • Hi David,

     

    Getting closer.  Now the error is raised on the last line.

     

    var name = xmlDoc.getElementsByTagName("name")[0].childNodes[0].nodeValue;

     

    Doesn't look like i'm parsing the value correctly.   Any thoughts or direction on how to extract the values? Basically, I'm trying to locate the name, currency label (i.e. Canadian Dollar), currency id, from the following responses.

     

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlnsTongue Tiedoap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
        <RetrieveMultipleResponse xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
          <RetrieveMultipleResult EntityName="account" MoreRecords="0" PagingCookie="">
            <BusinessEntities xmlns="http://schemas.microsoft.com/crm/2006/WebServices">
              <BusinessEntity xmlns:q1="http://schemas.microsoft.com/crm/2007/WebServices" xsi:type="q1:account">
                <q1:name>KISP Inc.</q1:name>
                <q1:transactioncurrencyid name="Canadian Dollar" dsc="0">{FD4D1238-60B9-DC11-A54A-0003FF6F4EC8}</q1:transactioncurrencyid>
                <q1:accountid>{438E5B0E-41BD-DC11-A52B-0003FF6F4EC8}</q1:accountid>
              </BusinessEntity>
            </BusinessEntities>
          </RetrieveMultipleResult>
        </RetrieveMultipleResponse>
      </soap:Body>
    </soap:Envelope>

     

    You're suggestions or comments are very much appreciated.  

    Sunday, January 27, 2008 1:38 AM
  • For the name element I'd use:

     

    var name = xmlDoc.getElementsByTagName("name")[0].text;

     

    And for currency:

     

    var currencylabel = xmlDoc.getElementsByTagName("transactioncurrencyid")[0].getAttribute('name');

     

    If these don't work I'd check if getElementsByTagName("name") returns anything. I don't think it is affected by xml namespaces, but that might be a problem

     

    Sunday, January 27, 2008 2:15 PM
    Moderator
  • alright .. the javascript saga continues tried the following but no luck.

     

    var name = xmlDoc.getElementsByTagName("name")[0].text; >> raises an error

     

    var name = xmlDoc.getElementsByTagName("name").text; .>> "undefined" but no error

     

    var name = xmlDoc.getElementsByTagName("name").nodeValue >> "undefined" but no error

     

    and

     

    var currencylabel = xmlDoc.getElementsByTagName("transactioncurrencyid")[0].getAttribute('name'); >> error the value is null.

     

    var currencylabel = xmlDoc.getElementsByTagName("transactioncurrencyid").getAttribute('name'); >> object does not support this property.

     

     

    Monday, January 28, 2008 2:48 AM
  • Dear Check this

     

    var userid = xmlDoc.getElementsByTagName("UserId")[0].childNodes[0].nodeValue;

     

    I trying this to get value

     

    var userid = xmlDoc.getElementsByTagName("transactioncurrencyid")[0].childNodes[0].nodeValue;

     

    For more you can see XML Document Element on CRM SDK.

     

    Best Regards,

    Imran

     

    http://microsoftcrm3.blogspot.com

     

    Monday, January 28, 2008 4:56 AM
    Moderator
  •  

    Hi Guys,

     

    ok so I figured it out .... the response attributes are being "wrapped" with at "q1:" prefix.  So "name" is actually "q1:name" etc.

     

    So David ... you're suggestions are working now (sorry Imran I have to give the answer to David he was first).

     

    Thanks for the assistance always appreciated.

     

    Michael

     

    Monday, January 28, 2008 2:08 PM
  • I do respect this, and recomend david for this answer. No wories

     

    Good Luck

     

    Regards,

    Imran

     

    http://microsoftcrm3.blogspot.com

     

     

    Monday, January 28, 2008 2:20 PM
    Moderator