Import Member/Contacts To A Marketing Segment

A segment in 365 for marketing app is an essential feature which lets you create a list of related contacts based on some criteria( similar to advanced find). Later it is used to target customers in a customer journey.

While you can define a criteria/search for contacts and add them in a Dynamic segment, you don’t have this facility in a “Static” Segment because contacts are manually added on a per-contact basis. hence, there should be ability to import these contacts in to a static segment. 

Now, there is no out of the box way I could find by which we can bulk update contacts into a segment, however after doing a bit digging, I found a working custom solution. 

Solution

If you look into segment entity, you will find a mysterious field named “msdyncrm_segmentmemberids” as below:

segment1

This field basically consists of the ids of the contacts in a JSON format prefixed with “crm”:

segment2

Hence, whatever contacts you manually select on the segment comes and sit in this field. So we just need to update this field with ids of the contact we want to include in this segment.

You can update this field either by WebApi or a Plugin. Its upto you how you want to design your solution. In my case I have placed button on the segment form which opens a web resource providing a flexibility to upload an excel/csv file containing these ids of the contacts which you can easily read, prepare the format of the guids(prefix with “crm”) and update using a simple web api request.

 var entity = {};
            var stringIfy = JSON.stringify(Prepared_ContactsArray);
            var entity = {};
            entity.msdyncrm_segmentmemberids = stringIfy;

            var req = new XMLHttpRequest();
            req.open("PATCH", GetGlobalContext().getClientUrl() + "/api/data/v9.1/msdyncrm_segments(" + segmentId + ")", true);
            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.onreadystatechange = function () {
                if (this.readyState === 4) {
                    req.onreadystatechange = null;
                    Xrm.Utility.closeProgressIndicator();
                    if (this.status === 204) {
                        //Success - No Return Data - Do Something
                       
                    } else {
                        //Xrm.Utility.alertDialog(this.statusText);
                    
                    }
                }
            };
            req.send(JSON.stringify(entity));
        }

I hope this helps!

Cheers!

Microsoft Dynamics CRM 2016/2015/2013- Dynamic and Static Marketing List

This has been a most population concept in marketing module of CRM ; i would like to share some crucial difference between them:

Dynamic marketing lists is able to save time and ensured that everyone that should be on the list was on the list.

A Static marketing list is a snapshot in time. You add the contacts you want in that marketing list depending on certain criteria…and that was it. If a new contact is added to the CRM database you can manually add them to the marketing list, or if the marketing list is no longer relevant to a contact you can manually remove them.

Dynamic marketing lists removes the manual element. You can create a query (e.g. all customers where their country equals Ireland). This means that any contacts with “Country = Ireland” will be added to the list. As you add new contacts to the CRM database, they will automatically be added to the marketing list if they live in Ireland. If a contact moves and the Country field in the contact card is updated, then they will be automatically removed from the marketing list.

 

Some other major differences below :

Dynamic List Static List
Member types Leads, Contacts or Accounts Leads, Contacts or Accounts
Adding members The query to select members automatically adds records which meet the criteria You can manually add records using the Add to Marketing List button
Manage Members – Add records using a lookup
Manage Members – Add records using an advanced find
Removing members Members are automatically removed if they no longer meet the dynamic list query criteria Manage Members – Advanced find to Remove records
Manage Members – advanced find to evaluate members
Blocked attribute You cannot block a dynamic list (you can use the copy to static button to copy the members of a dynamic list to a new static marketing list) You can block a static list, which stops members being added or deleted.
Updating list members automatic Manual – a static list has to be updated manually.
deactivated records/members Automatically excluded from the list
Can lists be added to a campaign Yes – All marketing lists can be added to a campaign and both static and dynamic can be added to the same campaign Yes – All marketing lists can be added to a campaign and both static and dynamic can be added to the same campaign

 

Happy CRM 🙂 cheers!!