Tuesday, July 28, 2009

Find login user of CRM using JavaScript

var xml = "" +
"" +
"< soap:envelope chema-instance="" chema="" envelope="" http:="" schemas.xmlsoap.org="" soap="" www.w3.org="" xmlns:soap="\ " xmlns:xsd="\ " xmlns:xsi="\ " >" +

GenerateAuthenticationHeader() +

" < soap:body >" +

" < retrievemultiple crm="" ebservices="" http:="" schemas.microsoft.com="" xmlns="\" >" +

" < query crm="" http:="" q1:queryexpression="" schemas.microsoft.com="" uery="" xmlns:q1="\" xsi:type="\" >" +

" < q1:entityname>systemuser< / q1:entityname >" +

" < q1:columnset q1:columnset="" xsi:type="\" >" +

" < q1:attributes >" +

" < q1:attribute>businessunitid < / q1:attribute >" +

" < q1:attribute>firstname< / q1:attribute >" +

" < q1:attribute>fullname" +

" < q1:attribute>lastname" +

" < q1:attribute>organizationid " +

" < q1:attribute>systemuserid" +

" < /q1:attributes >" +

" < /q1:columnset >" +

" < q1:distinct>false" +

" < q1:criteria >" +

" < q1:filteroperator>And" +

" < q1:conditions >" +

" < q1:condition >" +

" < q1:attributename>systemuserid" +

" < q1:operator>EqualUserId" +

" < / q1:condition >" +

" < / q1:conditions >" +

" < / q1:criteria >" +

" < / query >" +

" < / retrievemultiple >" +

" < / soap:body >" +

"< / soap:envelope >" +

"";



var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");



xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);

xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");

xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

xmlHttpRequest.setRequestHeader("Content-Length", xml.length);

xmlHttpRequest.send(xml);



var resultXml = xmlHttpRequest.responseXML;

var entityNode = resultXml.selectSingleNode("//RetrieveMultipleResult/BusinessEntities/BusinessEntity");



var firstNameNode = entityNode.selectSingleNode("q1:firstname").nodeTypedValue;

var lastNameNode = entityNode.selectSingleNode("q1:lastname").nodeTypedValue;

var fullNameNode = entityNode.selectSingleNode("q1:fullname").nodeTypedValue;

var systemUserIdNode = entityNode.selectSingleNode("q1:systemuserid").nodeTypedValue;

var businessUnitIdNode = entityNode.selectSingleNode("q1:businessunitid").nodeTypedValue;

var organizationIdNode = entityNode.selectSingleNode("q1:organizationid").nodeTypedValue;


alert(systemUserIdNode );

4 comments:

  1. I saw your post its fine but Webcrs award winning, beneficial CRM for Tour Operators provides everything for a small & large scale business operators to run their back office & sales operation in one easy powerful system! With webcrs travel CRM, tour operators can get entire 360degree customer view. For more details please visit our website: webcrstravel.com/

    ReplyDelete