Sunday, 15 March 2015

javascript - Looking up Address field on Custom Entity in CRM 2011 -



javascript - Looking up Address field on Custom Entity in CRM 2011 -

i have entity called client site store site information. site create devices (another custom entity). have created relevent address fields of address entity in client site entity , trying (based on account) fill site fields of selected address account.

i referred article doing so, http://xrmexpertz.com/2012/01/24/lookup-address-for-custom-entities-in-crm-2011/

i've altered javascript , xml provided in link reflect entities , web resource.

my problem when click button should execute javascript nothing, , if seek save site without business relationship sends me , error.

this java script.

function customlookup() { 'use strict'; var aoitems = getfieldvalue("kez_siteinfo_accountid"); if (aoitems == null) { alert(“account not selected”); return; } var _object = openstddlg(“ / sfa / quotes / dlg_lookupaddress.aspx ? headerform = 1 & parenttype = 1 & parentid = ” + aoitems[0].id + “ & willcall = 0″, “lookupaddress”, 500, 330, true); if (object) { setfieldvalue(“kez_address1_name”, object.address.name); setfieldvalue(“kez_address1_line1″, object.address.line1); setfieldvalue(“kez_address1_line2″, object.address.line2); setfieldvalue(“kez_address1_line3″, object.address.line3); setfieldvalue(“kez_address1_city”, object.address.city); setfieldvalue(“kez_address1_province”, object.address.stateorprovince); setfieldvalue(“kez_address1_postalcode”, object.address.postalcode); setfieldvalue(“kez_address1_country”, object.address.country); } } function setfieldvalue(fieldname, fieldvalue) { xrm.page.getattribute(fieldname).setvalue(fieldvalue); }

this error gives

microsoft dynamics crm error study contents <crmscripterrorreport> <reportversion>1.0</reportversion> <scripterrordetails> <message>uncaught syntaxerror: unexpected token illegal</message> <line>7</line> <url>/%7b634962800260003236%7d/webresources/kez_getlocation</url> <pageurl>/userdefined/edit.aspx?_gridtype=10018&etc=10018&id=%7b1f8e02f0-766c-e211-934e- 00155d018211%7d&pagemode=iframe&preloadcache=1360684076423&rskey=69426415</pageurl> <function></function> <callstack> </callstack> </scripterrordetails> <clientinformation> <browseruseragent>mozilla/5.0 (windows nt 6.2) applewebkit/537.30 (khtml, gecko) chrome/26.0.1403.0 safari/537.30</browseruseragent> <browserlanguage>undefined</browserlanguage> <systemlanguage>undefined</systemlanguage> <userlanguage>undefined</userlanguage> <screenresolution>1366x768</screenresolution> <clientname>web</clientname> <clienttime>2013-02-12t10:47:58</clienttime> </clientinformation> <serverinformation> <orglanguage>1033</orglanguage> <orgculture>1033</orgculture> <userlanguage>1033</userlanguage> <userculture>1033</userculture> <orgid>{bc278bc1-eeea-4d24-b5c6-f0720b343a1f}</orgid> <userid>{d76eea89-d760-e211-921f-00155d018211}</userid> <crmversion>5.0.9690.3236</crmversion> </serverinformation> </crmscripterrorreport>

i ended solving problem, 1 source listed uses quotes not recognized crm. next had utilize xrm.getattribute instead of getfieldvalue.

the final , working code below:

function customlookup() { 'use strict'; var aoitems = xrm.page.getattribute('kez_siteinfo_accountid').getvalue(); if (aoitems == null) { alert("account not selected"); return; } var _object = openstddlg("/sfa/quotes/dlg_lookupaddress.aspx?headerform=1&parenttype=1&parentid=" + aoitems[0].id + "&willcall=0", "lookupaddress", 500, 330, true); if (object) { setfieldvalue("kez_address1_name", object.address.name); setfieldvalue("kez_address1_line1", object.address.line1); setfieldvalue("kez_address1_line2", object.address.line2); setfieldvalue("kez_address1_line3", object.address.line3); setfieldvalue("kez_address1_city", object.address.city); setfieldvalue("kez_address1_province", object.address.stateorprovince); setfieldvalue("kez_address1_postalcode", object.address.postalcode); setfieldvalue("kez_address1_country", object.address.country); } } function setfieldvalue(fieldname, fieldvalue) { xrm.page.getattribute(fieldname).setvalue(fieldvalue); }

javascript dynamics-crm-2011 dynamics-crm lookup

No comments:

Post a Comment