Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Error with custom javascript code when retrieve Customer from Case

$
0
0

I have a issue with some javascript code. i use retrieve multiple to get customerid from case like bellow.

When i try to run the code i get a error message: "Generic SQL Error", and in the crm/sql logs i get this message: "Invalid Column name 'CustomeridDsc'"

But the more interesting part of this problem is this: in the security roles i have the Account and the Case entity at BU level and if i pass to parent BU this issue persists but if i put at organization level the error disappear and i get the account normally and fill what i want in the form.

GetCase = function () {

    if (crmForm.all.regardingobjectid.DataValue != null) {

  var entityName = "incident";

       var authenticationHeader = GenerateAuthenticationHeader();

 

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>"+ 

"<RetrieveMultiple xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+ 

"<query xmlns:q1='http://schemas.microsoft.com/crm/2006/Query'"+

" xsi:type='q1:QueryExpression'>"+ 

"<q1:EntityName>" + entityName + "</q1:EntityName>"+ 

"<q1:ColumnSet xsi:type='q1:ColumnSet'>" +

"<q1:Attributes>" +

"<q1:Attribute>customerid</q1:Attribute>" +

"</q1:Attributes>" +

"</q1:ColumnSet>" +

"<q1:Distinct>false</q1:Distinct>"+ 

"<q1:Criteria>"+ 

"<q1:FilterOperator>And</q1:FilterOperator>"+ 

"<q1:Conditions>"+ 

"<q1:Condition>"+ 

"<q1:AttributeName>incidentid</q1:AttributeName>"+ 

"<q1:Operator>Like</q1:Operator>"+ 

"<q1:Values>"+ 

"<q1:Value xsi:type='xsd:string'>"+ crmForm.all.regardingobjectid.DataValue[0].id +"</q1:Value>"+ 

"</q1:Values>"+ 

"</q1:Condition>"+ 

"</q1:Conditions>"+ 

"</q1:Criteria>"+ 

"</query>"+ 

"</RetrieveMultiple>"+ 

"</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/RetrieveMultiple");

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;

 

// Check for errors.

var errorCount = resultXML.selectNodes('//error').length;

if (errorCount != 0)

{

var msg = resultXML.selectSingleNode('//description').nodeTypedValue;

alert(msg);

}

        //Parse and display the results.

        else {

            var results = resultXML.getElementsByTagName('BusinessEntity');

            var msg = "";

            if (results.length != 0) {

                if (resultXML.getElementsByTagName('q1:customerid').length > 0) {

                    //Set the default account

                    var lookupData = new Array();

                    var lookupItem = new Object();

                    lookupItem.id = resultXML.getElementsByTagName('q1:customerid')[0].childNodes[0].nodeValue;

                    lookupItem.typename = 'account';

                    lookupItem.name = resultXML.getElementsByTagName('q1:customerid')[0].attributes.getNamedItem('name').value;

                    lookupData[0] = lookupItem;

                    Xrm.Page.getAttribute("myp_customerid").setValue(lookupData);

 

                    GetAccount(resultXML.getElementsByTagName('q1:customerid')[0].childNodes[0].nodeValue);

                }

            }

            else {

            }

        }

    }

}

 

 

 

 

 


Viewing all articles
Browse latest Browse all 82002

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>