Sample Code to Retrieve all the members of a Static Marketing List in CRM 2011


Hi,

Below is the code that we could use to retrieve the GUIDs of all the members associated to a STATIC marketing list.

 private void GetAllMembers_Click(object sender, EventArgs e)
 {
 ArrayList memberGuids = new ArrayList();
 IOrganizationService orgService = GetOrganizationService();

PagingInfo pageInfo = new PagingInfo();
 pageInfo.Count = 5000;
 pageInfo.PageNumber = 1;

QueryByAttribute query = new QueryByAttribute("listmember");
 // pass the guid of the Static marketing list
 query.AddAttributeValue("listid", new Guid("2CA7881F-3EDA-E111-B988-00155D886334"));
 query.ColumnSet = new ColumnSet(true);
 EntityCollection entityCollection = orgService.RetrieveMultiple(query);

foreach (Entity entity in entityCollection.Entities)
 {
 memberGuids.Add(((EntityReference) entity.Attributes["entityid"]).Id);
 }

// if list contains more than 5000 records
 while (entityCollection.MoreRecords)
 {
 query.PageInfo.PageNumber += 1;
 query.PageInfo.PagingCookie = entityCollection.PagingCookie;
 entityCollection = orgService.RetrieveMultiple(query);

foreach (Entity entity in entityCollection.Entities)
 {
 memberGuids.Add(((EntityReference)entity.Attributes["entityid"]).Id);
 }
 }

}

public IOrganizationService GetOrganizationService()
 {
 Uri organizationUri = new Uri("http://servername/orgname/XRMServices/2011/Organization.svc");
 Uri homeRealmUri = null;
 ClientCredentials credentials = new ClientCredentials();
 credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
 OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
 IOrganizationService _service = (IOrganizationService)orgProxy;
 return _service;
 }

Hope it helps.


Thanks Hosk for your appreciation.

Hosk's avatarHosk's Dynamic Blog

Microsoft Dynamics world recently had a survey to find out the best CRM blogs, Richard Knudson discusses the top 5 on his blog this week, which you can read about here.  Although Richard is talking about it because he is featured at number 4.  He certainly deserves to be in the top 5, his blog is consistently excellent, especially considering he is a one man band, where as other blogs featured have a few contributors.

Since I have been using Netvibes I can subscribe to lots of CRM blogs but it is these 5 which produce some of the best articles.  Not only do they produce the best blog entries but the volume of blog entries is incredible from these blogs

Here’s an executive summary, starting with the listing of the top five:

  1. The official Microsoft Dynamics Team Blog
  2. The Customer Effective Blog
  3. A CRM Riff by Jim Glass
  4. Richard Knudson’s Dynamics CRM Trick Bag (this…

View original post 19 more words


Danny Varghese's avatarDanny Varghese's Blog

There’s a new property called “NoLock” added to the QueryExpression class for Microsoft Dynamics CRM 2011.  I found this researching a locking issue on the database we were having for a client.    According to the Microsoft CRM 2011 SDK:

“The benefit of setting NoLock to true is that it allows you to keep the system from issuing locks against the entities in your queries; this increases concurrency and performance because the database engine does not have to maintain the shared locks involved. The downside is that, because no locks are issued against the records being read, some “dirty” or uncommitted data could potentially be read. A “dirty” read is one in which the data being read is involved in a transaction from another connection. If that transaction rolls back its work, the data read from the query using NoLock will have read uncommitted data. This type of read makes…

View original post 35 more words

How to – Pass parameters to JavaScript Web Resource function in CRM 2011.


Hi,

Suppose we want to pass few values as parameter to our JavaScript function.

Here we have a JavaScript library named new_test which has GetParameters function.

Here we are passing three parameters

  1. Pass execution context as first parameter. (Check box)

Using getEventSource method we can get the name attribute’s value.

  1. Sample String Parameter” = string value.
  2. name” = string value with schema name of the “name” attribute.

We can use the attribute’s  name in our Xrm.page.getAttribute method.

The JavaScript function

The alert box

Hope it helps!

Advertisements

Showing custom warning message on an entity form in CRM


Hi,

I was searching for a way to show custom warning message in an entity’s form and came across these two helpful posts

For CRM 4 :-

http://social.microsoft.com/Forums/br/crmdevelopment/thread/1791ab40-a1e6-4099-bb4b-6e52a9a45c18

For CRM 2011 : –

http://crm2011wiki.wordpress.com/2012/04/16/showing-custom-alerts-in-notifications-area/

Hope it helps.

 

“Object doesn’t support property or method ‘setFormMode’” error while closing the record’s form in CRM 2011.


Hi,

We had recently written a plugin for sending email. In the description of the email we were inserting the URL of the record

string recordUrl = string.Format(“<a href=’{0}/userdefined/edit.aspx?etc=4300&id={1}‘>Click here to open the record</a>”, this.serverName, marketingListGuid.ToString());

While clicking the link the record opens properly, however when we try closing the form’s window we get the below error

We have UR8 installed in our on premise development environment there we don’t get this error, however we are still getting the above error for our online dev and production environment.

http://social.microsoft.com/Forums/lv-LV/crmdevelopment/thread/0c0aa09e-0ea6-4150-8056-a2b7b91f3256?prof=required

Bye.

Nishant Rana's Weblog

Everything related to Microsoft .NET Technology

Skip to content ↓