How To : Retrieve the Marketing Lists Count Associated With An Event in CRM Using JavaScript

Hi, in this article am gonna show how to retrieve marketing lists count associated with certain event in CRM Using JavaScript.

Code:

function retrieveEventAssociatedLists(EventID) {

var listsCount = 0;

var serverUrl = "http://" + document.location.href.split("/")[2];

var ODataPath = serverUrl + "/OrganizationName/XRMServices/2011/OrganizationData.svc";

var retrieveEventListsReq = new XMLHttpRequest();

retrieveEventListsReq.open("GET", ODataPath + "/new_new_event_listSet?$filter=new_eventid eq guid'" + EventID + "'",   false);

retrieveEventListsReq.setRequestHeader("Accept", "application/json");

retrieveEventListsReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");

retrieveEventListsReq.send();

if (retrieveEventListsReq.status == 200) {

//Success

var retrievedEventLists = JSON.parse(retrieveEventListsReq.responseText).d;

listsCount = retrievedEventLists.results.length;

}

return listsCount;

}

Leave a Reply

Your email address will not be published. Required fields are marked *