locked
CRM4 Lookup and Setting a Money Value RRS feed

  • Question

  • Hi,

    The code below is meant to lookup a Price from a Product selected on a quote product. I need to be able to set the value it looks up as a Money field on the quote product but it doesnt like it.

    Can anyone help? Thanks

    var SelectedProduct = crmForm.all.productid.DataValue;
    if (SelectedProduct != null)
    {
     var ProductID = SelectedProduct[0].id;
     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'>"+
     GenerateAuthenticationHeader()+
     "<soap:Body>"+
     "<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
     "<entityName>product</entityName>"+
     "<id>"+ProductID+"</id>"+
     "<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+
     "<q1:Attributes>"+
     "<q1:Attribute>price</q1:Attribute>"+
     "<q1:Attribute>currentcost</q1:Attribute>"+
     "</q1:Attributes>"+
     "</columnSet>"+
     "</Retrieve>"+
     "</soap:Body>"+
     "</soap:Envelope>";
     var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
     xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
     xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
     xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
     xHReq.setRequestHeader("Content-Length", xml.length);
     xHReq.send(xml);
     var resultXml = xHReq.responseXML;  
     if (crmForm.all.productid.DataValue != null)
     {
      var orgppu = resultXml.selectSingleNode("//q1:price");
      crmForm.all.pm_newppu.DataValue = orgppu;


       }
    }

     


    Pete
    Tuesday, June 15, 2010 11:31 AM

Answers

  • Try to replace code

     var orgppu = resultXml.selectSingleNode("//q1:price");
     crmForm.all.pm_newppu.DataValue = orgppu;

    with following:

    var orgppu = resultXml.selectSingleNode("//q1:price");
    if (orgppu != null)
    {
    	 crmForm.all.pm_newppu.DataValue = parseFloat(orgppu.nodeTypedValue);
    }


    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)
    • Marked as answer by Pete.UK Wednesday, June 16, 2010 10:37 AM
    Tuesday, June 15, 2010 2:55 PM
    Moderator

All replies

  • What is the error message?
    Tuesday, June 15, 2010 12:32 PM
  • the error is "this control only accepts numbers or null as an input"
    Pete
    Tuesday, June 15, 2010 2:34 PM
  • Try to replace code

     var orgppu = resultXml.selectSingleNode("//q1:price");
     crmForm.all.pm_newppu.DataValue = orgppu;

    with following:

    var orgppu = resultXml.selectSingleNode("//q1:price");
    if (orgppu != null)
    {
    	 crmForm.all.pm_newppu.DataValue = parseFloat(orgppu.nodeTypedValue);
    }


    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)
    • Marked as answer by Pete.UK Wednesday, June 16, 2010 10:37 AM
    Tuesday, June 15, 2010 2:55 PM
    Moderator