locked
Export Dynamics Marketing Lists with related queries RRS feed

  • Question

  • Hi,

    I have 65 Dynamic Marketing Lists with different queries for each one and I would like to export these Marketing lists to three different environments (i.e. to UAT/Production), it will be extremely wasting of time and tedious task to build the query Sixty Five times for each environment we have.

    So the only attributes that can be exported are Name, Type, Member Type and some other attributes, what I need really to export is the queries with each Dynamics Marketing lists.

    I hope someone passed through same experience and can share any ideas! 

    Thanks


    Tamim ALKhiamy

    Sunday, April 13, 2014 1:25 AM

Answers

  • Hi Tamim,

    One possible idea is to write a simple console app that gets all dynamic Marketing lists from your source organisation then create them in your target organisation. Here is some tested sample code snippet that will do this for you. Hope this helps.

    private static void ExportDynamicMarketingLists(IOrganizationService _serviceProxyfrom, IOrganizationService _serviceProxyto)
    {
    	QueryExpression query = new QueryExpression("list");	// == marketing list
    	query.ColumnSet.AllColumns = true;			// get all columns
    	query.Criteria = new FilterExpression();
    	query.Criteria.AddCondition("type", ConditionOperator.Equal, true);	// Type == Dynamic
    	query.Criteria.AddCondition("statuscode", ConditionOperator.Equal, 0);	// active Marketing lists
    	EntityCollection results = _serviceProxyfrom.RetrieveMultiple(query); 
    
    	foreach(Entity ent in results.Entities)
    	{
    		// Clone the Marketing List to new ORG.
    		ent.Attributes.Remove("listid");	// but first remove the marketing list guid and create a new one
    		ent.Id = Guid.NewGuid();
    		var newMListId = _serviceProxyto.Create(ent);
    	}
    }


    Eric UNG [Senior Analyst Programmer :: Sydney, Australia]

    Sunday, April 13, 2014 7:18 AM

All replies

  • Hi Tamim,

    One possible idea is to write a simple console app that gets all dynamic Marketing lists from your source organisation then create them in your target organisation. Here is some tested sample code snippet that will do this for you. Hope this helps.

    private static void ExportDynamicMarketingLists(IOrganizationService _serviceProxyfrom, IOrganizationService _serviceProxyto)
    {
    	QueryExpression query = new QueryExpression("list");	// == marketing list
    	query.ColumnSet.AllColumns = true;			// get all columns
    	query.Criteria = new FilterExpression();
    	query.Criteria.AddCondition("type", ConditionOperator.Equal, true);	// Type == Dynamic
    	query.Criteria.AddCondition("statuscode", ConditionOperator.Equal, 0);	// active Marketing lists
    	EntityCollection results = _serviceProxyfrom.RetrieveMultiple(query); 
    
    	foreach(Entity ent in results.Entities)
    	{
    		// Clone the Marketing List to new ORG.
    		ent.Attributes.Remove("listid");	// but first remove the marketing list guid and create a new one
    		ent.Id = Guid.NewGuid();
    		var newMListId = _serviceProxyto.Create(ent);
    	}
    }


    Eric UNG [Senior Analyst Programmer :: Sydney, Australia]

    Sunday, April 13, 2014 7:18 AM
  • Monday, April 14, 2014 11:24 PM