locked
CRM 2011: Export unmanagned solutions through code RRS feed

  • Question

  • Hello Everyone

    What I am trying to do is to make a "versionhandler" for our customizations. We are doing a lot of development in different CRM systems for our customers and we don't need to backup data, only meta data is interesting for us, so I am trying to develop a simple plugin.

    However there seems to be some kind of error in processing my retrieve multiple, this is what I do:

    QueryExpression
     solutionsQuery = new
     QueryExpression
    ("solution"
    );
    solutionsQuery.Criteria.AddCondition("ismanaged"ConditionOperator .Equal, false );
    solutionsQuery.ColumnSet.AddColumns("uniquename""ismanaged" );
    EntityCollection  solutionCollection = service.RetrieveMultiple(solutionsQuery);

    Now I get 4 Solutions, first mine, then 3 more.

    Active, Default, and Basic. Which if I try to export, I get an error stating that:

    Managed solutions cannot be exported

    I check for ismanaged property, and I even get that back and check for it again, still exception...

    What am I doing wrong?

    Friday, March 11, 2011 3:03 PM

Answers

  • Well I know that I can Query for Solutions by using their name. However it doesn't fit my purpose. I want to export every solution that I can (which are the unmanaged once). Well I just have to find another criteria that fits my purpose.

    Perhaps something like:

     

    <fetch mapping="logical" count="50" version="1.0">
    	<entity name="solution">
    		<filter>
    			<condition attribute="isvisible" operator="eq" value="1" />
    			<condition attribute="ismanaged" operator="eq" value="0" />
    		</filter>
    		<link-entity name="systemuser" from="systemuserid" to="createdby">
    			<filter>
    				<condition attribute="fullname" operator="ne" value="SYSTEM" />
    			</filter>
    		</link-entity>
    	</entity>
    </fetch><br/>
    
    

    Well this seems to work for me. Now I get every Solution that is not managed, however I think that the property ismanaged should be enough...

    • Marked as answer by maeg02 Monday, March 14, 2011 6:57 AM
    Monday, March 14, 2011 6:56 AM

All replies

  • The SDK Sample: Work with solutions provides this code:

              // Retrieve a solution
              String solutionUniqueName = "samplesolution";
              QueryExpression querySampleSolution = new QueryExpression
              {
                EntityName = Solution.EntityLogicalName,
                ColumnSet = new ColumnSet(new string[] { "publisherid", "installedon", "version", "versionnumber", "friendlyname" }),
                Criteria = new FilterExpression()
              };
    
              querySampleSolution.Criteria.AddCondition("uniquename", ConditionOperator.Equal, solutionUniqueName);
              Solution SampleSolution = (Solution)_serviceProxy.RetrieveMultiple(querySampleSolution).Entities[0];
    

    All you need is the unique name for the solution.

    You should be able to export the Default solution - but not as an managed solution.

    Don't try to export the Active or Basic solutions. Just filter them out.


    Jim Daly Technical Writer Microsoft Dynamics CRM
    Saturday, March 12, 2011 12:22 AM
    Answerer
  • Well I know that I can Query for Solutions by using their name. However it doesn't fit my purpose. I want to export every solution that I can (which are the unmanaged once). Well I just have to find another criteria that fits my purpose.

    Perhaps something like:

     

    <fetch mapping="logical" count="50" version="1.0">
    	<entity name="solution">
    		<filter>
    			<condition attribute="isvisible" operator="eq" value="1" />
    			<condition attribute="ismanaged" operator="eq" value="0" />
    		</filter>
    		<link-entity name="systemuser" from="systemuserid" to="createdby">
    			<filter>
    				<condition attribute="fullname" operator="ne" value="SYSTEM" />
    			</filter>
    		</link-entity>
    	</entity>
    </fetch><br/>
    
    

    Well this seems to work for me. Now I get every Solution that is not managed, however I think that the property ismanaged should be enough...

    • Marked as answer by maeg02 Monday, March 14, 2011 6:57 AM
    Monday, March 14, 2011 6:56 AM