soap - Get attribute of lookup value - javascript / CRM 2011 -
i populate description of crm case description of chosen subject (case description disabled until subject chosen). use auto-populate questions based on subject. how retrieve subject description? can id , subject name can't seem find on web goes through more attributes 2.
thanks lot!
laurent
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>" + " <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>subject</q1:entityname>" + " <q1:columnset xsi:type=\"q1:columnset\">" + " <q1:attributes>" + " <q1:attribute>description</q1:attribute>" + " </q1:attributes>" + " </q1:columnset>" + " <q1:distinct>false</q1:distinct>" + " <q1:criteria>" + " <q1:filteroperator>and</q1:filteroperator>" + " <q1:conditions>" + " <q1:condition>" + " <q1:attributename>subjectid</q1:attributename>" + " <q1:operator>equal</q1:operator>" + " <q1:value xsi:type='xsd:string'>" + xrm.page.getattribute("subjectid").getvalue() + "</q1:value>" + " </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 subjectnode = entitynode.selectsinglenode("q1:description"); alert(subjectnode); xrm.page.getattribute("description").setvalue(subjectnode);
if returning 1 item suggest use "retrieve" not "retrievemultiple". have done above can description field including "description" in column list.
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>subject</entityname>" + "<id>" + xrm.page.getattribute("subjectid").getvalue()[0].id + "</id>" + "<columnset xmlns:q1='http://schemas.microsoft.com/crm/2006/query' xsi:type='q1:columnset'>" + "<q1:attributes>" + "<q1:attribute>description</q1:attribute>" + "</q1:attributes>" + "</columnset>" + "</retrieve>" + "</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/retrieve"); xmlhttprequest.setrequestheader("content-type", "text/xml; charset=utf-8"); xmlhttprequest.setrequestheader("content-length", xml.length); xmlhttprequest.send(xml); var resultxml = xmlhttprequest.responsexml; if (resultxml.selectsinglenode("//q1:description") != null) { xrm.page.getattribute("description").setvalue(resultxml.selectsinglenode("//q1:description").nodetypedvalue); }
Comments
Post a Comment