update ,delete contacts from static marketing list through plugin in mscrm 2011 RRS feed

  • Question

  • Dear all;

    i have a requirement that if i update a contact and that contact is a part of static markeitng list then i have to update the static marketing list wtih the updated information of the contact any idea how can i do it ???

    Friday, June 14, 2013 12:52 PM

All replies

  • Hi,

    Most probably you will have to write a custom workflow to fulfill this requirement. Can you be more speific about what you need to update on the marketing list?

    Friday, June 14, 2013 1:08 PM
  • HI Anwar,

    You can fire the plugin on update and delete what ever u want. In that plugin you can execute the below requests to retrieve, then you can update the fields what you want.

    Actually marketinglist and and marketinglistmembers(contacts,account,lead) having N:N relationship.

    Below i am placing two sample requests to retrieve N:N relationship records. one is fetchxml request and anotherone is linkentity request.

    you can use anyone of this request and You will get the marketinglist which is related to that contact and viceversa.


    string fetchquery = "<fetch distinct='true' mapping='logical' output-format='xml-platform' version='1.0'>"+
                                    "<entity name='contact'>"+
                                    "<attribute name='contactid'/>"+
                                    "<attribute name='lastname'/>"+
                                    "<attribute name='firstname'/>"+
                                    "<attribute name='address1_postalcode'/>"+
                                    "<attribute name='address1_line3'/>"+
                                    "<attribute name='address1_line2'/>"+
                                    "<attribute name='address1_line1'/>"+
                                    "<attribute name='address1_city'/>"+
                                    "<attribute name='parentcustomerid'/>"+
                                    "<link-entity name='listmember' intersect='true' visible='false' to='contactid' from='entityid'>"+
                                    "<link-entity name='list' to='listid' from='listid' alias='aj'>"+
                                    "<filter type='and'>"+
                                    "<condition attribute='listid' value='{"+listid+"}' uitype='list' operator='eq'/>"+

     RetrieveMultipleRequest req = new RetrieveMultipleRequest();
                FetchExpression fetch = new FetchExpression(fetchquery);
                req.Query = fetch;
                RetrieveMultipleResponse resp = (RetrieveMultipleResponse)service.Execute(req);



    LinkEntity filterLinkEntity = new LinkEntity();
                filterLinkEntity.LinkToEntityName = "entity1 name";
                filterLinkEntity.LinkFromAttributeName = "entity1 id(primarykey)";
                filterLinkEntity.LinkToAttributeName = "entity1 id(primarykey)";
                filterLinkEntity.LinkCriteria = filter;

                LinkEntity linkTableEntity = new LinkEntity();
                linkTableEntity.LinkToEntityName = "relationshipname";
                linkTableEntity.LinkFromAttributeName = "entity2id(primarykey)";
                linkTableEntity.LinkToAttributeName = "entity2id(primarykey)";

                RetrieveMultipleRequest req = new RetrieveMultipleRequest();
                req.Query = query;
                RetrieveMultipleResponse res = (RetrieveMultipleResponse)service.Execute(req);

    Thanks &regards

    sravan J

    • Edited by sravan J Friday, June 14, 2013 2:09 PM
    • Proposed as answer by Paul at Clew Thursday, June 20, 2013 9:29 AM
    Friday, June 14, 2013 2:08 PM