Hi,
i have lookup entity "Distribution list" that i display in custom entity "sms" in subgrid (N-N), also the "Distribution list" entity contain users from the systemuser entity (N-N).
-I can select more than marketing list
-I want when i select the Marketing list to execute JScript to get theur users and store them in sms entity's custom option set field.
-the code that i try is bellow, but nothing happen the code is bellow :
function storeDlistPhones() { var gridControl = document.getElementById('DistributionList').control; var ids = gridControl.get_allRecordIds(); for(i = 0; i < ids.length; i++) { var lisguid=gridControl.getCellValue('new_name', ids[i]); var serverUrl = Xrm.Page.context.getClientUrl(); var oDataSelect =serverUrl + "/new_distributionlistSet?$select=new_new_distributionlist_systemuser/FullName,new_new_distributionlist_systemuser/MobilePhone&$expand=new_new_distributionlist_systemuser&$filter=new_name eq '"+lisguid+ "'"; var retrieveReq = new XMLHttpRequest(); retrieveReq.open("GET", oDataSelect, false); retrieveReq.setRequestHeader("Accept", "application/json"); retrieveReq.setRequestHeader("Content-Type", "application/json;charset=utf-8"); retrieveReq.onreadystatechange = function () { GetContactData(this); }; retrieveReq.send(); } } function GetContactData(retrieveReq) { if (retrieveReq.readyState == 4) { if (retrieveReq.status == 200) { var retrieved = JSON.parse(retrieveReq.responseText).d; varmessage=retrieved.results[0].MobilePhone; //---here i need to make a loop for the retrieved data count to store it in the option set----------------- Xrm.Page.getAttribute("new_smsrecipient").addOption(varmessage, 0); } } }