Forum Post: RE: On creation of Associate record set field lookup from subgrid related record in crm 365 using javascript

0
40
Forum Post: Change the Filter On option on Opportunity Associated View for Account form



I have used below code its working fine. var req = new XMLHttpRequest(); req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/campaignactivities?$select=activityid,subject,_wcl_technicalactivity_value&$filter=_wcl_technicalactivity_value eq '" + newID + "'", true); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.setRequestHeader("Prefer", "odata.include-annotations=\"*\""); req.onreadystatechange = function () { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 200) { var results = JSON.parse(this.response); for (var i = 0; i < results.value.length; i++) { if (results.value[i]["activityid"] !== null) var activityid = results.value[i]["activityid"]; if (results.value[i]["subject"] !== null) var subject = results.value[i]["subject"]; if (results.value[i]["_wcl_technicalactivity_value"] !== null) { var _wcl_technicalactivity_value = results.value[i]["_wcl_technicalactivity_value"]; var _wcl_technicalactivity_value_formatted = results.value[i]["[email protected]dValue"]; var _wcl_technicalactivity_value_lookuplogicalname = results.value[i]["[email protected]lname"]; } var value = new Array(); //create a new object array value[0] = new Object(); value[0].id = activityid; // set ID to ID value[0].name = subject; //set name to name value[0].entityType = "campaignactivity"; // entity schema name if (formContext.getAttribute("wcl_catechnicalactivityattendanceid") !== null) formContext.getAttribute("wcl_catechnicalactivityattendanceid").setValue(value);



Source link

Leave a reply

Please enter your comment!
Please enter your name here