Guys need to get the related lead id from the campaign entity in java script
*This post is locked for comments
Guys need to get the related lead id from the campaign entity in java script
*This post is locked for comments
When I added the code as above function getting an error like One of the scripts for this record has caused an error. For more details, download the log file.
ReferenceError: **** is not defined at eval
Then use the below code:
var req = new XMLHttpRequest(); req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/leads?$select=_campaignid_value,_customerid_value,leadid&$filter=_campaignid_value eq 00000000-CAMPAIGN-GUID-00000000", false); 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++) { var leadid = results.value[i]["leadid"]; //YOUR REQUIRED LEADID } } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send();
Hi Piyush, thanks for the reply but we don't have leadid lookup field in the campaign form and we have grid loading with leads that are related to Campaign
Hi Kishor,
Assuming, you have leadid lookup field in campaign entity form, then use below code to get the lead id:
Xrm.Page.getAttribute("leadid").getValue()[0].id;
Hope it help you!
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156