function weeklyReport_OnLoad() { //only on create if (Xrm.Page.ui.getFormType() == 1) { var id = Xrm.Page.context.getUserId(); id = id.replace("{", "").replace("}", ""); var req = new XMLHttpRequest(); req.open("GET", Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/SystemUserSet(guid'" + id + "')?$select=am_DWTerritory", true); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.onreadystatechange = function() { if (this.readyState === 4) { this.onreadystatechange = null; if (this.status === 200) { var result = JSON.parse(this.responseText).d; var am_DWTerritory = result.am_DWTerritory; // alert("Setting DW Territory"); // console.log(am_DWTerritory); // alert(am_DWTerritory.Name); Xrm.Page.getAttribute("dwterritory").setValue(am_DWTerritory); } else { alert(this.statusText); } } }; req.send(); } }
*This post is locked for comments
what's the data type of am_DWTerritory?
Hey,
what error are you getting?
I think you must try to debug - you will know where and why its failing.
Its a lookup field. The console.log returns an object which I try to use in setValue.
No errors are thrown.
Is there any error if you debug? Xrm.Page.getAttribute("dwterritory").setValue(am_DWTerritory);
Can you double check the field name? Maybe prefix is missed?
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
UllrSki 2
Community Member 2
SC-08081331-0 1