Michael Philip's Blog

Writing about MS Tech with strong focus on Azure & CRM

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

Leave a comment

Hi, in this article am gonna show how to retrieve marketing lists count associated with certain event in CRM 2011 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;

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s