locked
CRM 2011 crmsvcutil generated enum option sets RRS feed

  • Question

  • Hi All,

    So I've used the CrmSvcUtil.exe to generate strong types for my entities and enums for my option sets.

    Here is one of the generated enums.

    	[GeneratedCode("CrmSvcUtil""5.0.9688.1244")]
    	[DataContract]
    	public enum LeadType
    	{
    		[EnumMember]
    		LeadA = 1,
    		[EnumMember]
    		LeadB = 2,
    	}
    But the actual values for this via the CRM customization is LeadA = 0, LeadB = 1.
    Any idea what's going on here?
    Thanks for any advice/suggestions.
    Jon

    Wednesday, November 2, 2011 5:31 PM

Answers

  • I just used the generatepicklistenums extension provided in SDK to test out the problem that you have described, the following is what I have got. 

     

    [System.Runtime.Serialization.DataContractAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "5.0.9688.1533")]
    public enum new_leadtype
    {
    	
    	[System.Runtime.Serialization.EnumMemberAttribute()]
    	LeadA = 0,
    	
    	[System.Runtime.Serialization.EnumMemberAttribute()]
    	LeadB = 1,
    }
    
    [System.Runtime.Serialization.DataContractAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "5.0.9688.1533")]
    public enum Leadnew_LeadType
    {
    	
    	[System.Runtime.Serialization.EnumMemberAttribute()]
    	LeadA = 0,
    	
    	[System.Runtime.Serialization.EnumMemberAttribute()]
    	LeadB = 1,
    }
    

    It seems that it has worked fine for me. 

     

    Do you happen to have both global optionset and an entity optionset defined, but they are using different enumeration options? 


    Daniel Cai | http://danielcai.blogspot.com | Tata Solutions Inc.
    • Marked as answer by Goosey314159 Thursday, November 3, 2011 6:00 PM
    Wednesday, November 2, 2011 10:31 PM

All replies

  • This is very likely an application bug if it happens (though I haven't verified myself). Did you try a more recent version of CrmSvcUtil? 
    Daniel Cai | http://danielcai.blogspot.com | Tata Solutions Inc.
    Wednesday, November 2, 2011 7:17 PM
  • Thanks for the idea.

    Just downloaded and tried to use the 5.0.7 SDK (previous was the 5.0.6) and got the same result.

     

    	[System.Runtime.Serialization.DataContractAttribute()]
    	[System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil""5.0.9688.1533")]
    	public enum LeadType
    	{
    		
    		[System.Runtime.Serialization.EnumMemberAttribute()]
    		LeadA = 1,
    		
    		[System.Runtime.Serialization.EnumMemberAttribute()]
    		LeadB = 2,
    	}
    Something else I noticed in the StringMap table 

    AttributeName	AttributeValue	Value	VersionNumber
    LeadType	0		LeadA	0x0000000008133206
    LeadType	1		LeadB	0x0000000008133207
    LeadType	0		LeadA	0x0000000006E0F7C2
    LeadType	1		LeadB	0x0000000006E0F7C3
    LeadType	1		LeadA	0x0000000007AD9381
    LeadType	2		LeadB	0x0000000007AD9382

    It looks like in the DB there is a set of 1 and 2 values, which would match the enum but not the LeadType bool property.
    So in one of my early-bound entities I have MyEntity.LeadType which is of type "Two Options" on the CRM side and a bool on the entity side.

    I'm lost :(
    -Jon

     

    Wednesday, November 2, 2011 8:08 PM
  • I just used the generatepicklistenums extension provided in SDK to test out the problem that you have described, the following is what I have got. 

     

    [System.Runtime.Serialization.DataContractAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "5.0.9688.1533")]
    public enum new_leadtype
    {
    	
    	[System.Runtime.Serialization.EnumMemberAttribute()]
    	LeadA = 0,
    	
    	[System.Runtime.Serialization.EnumMemberAttribute()]
    	LeadB = 1,
    }
    
    [System.Runtime.Serialization.DataContractAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "5.0.9688.1533")]
    public enum Leadnew_LeadType
    {
    	
    	[System.Runtime.Serialization.EnumMemberAttribute()]
    	LeadA = 0,
    	
    	[System.Runtime.Serialization.EnumMemberAttribute()]
    	LeadB = 1,
    }
    

    It seems that it has worked fine for me. 

     

    Do you happen to have both global optionset and an entity optionset defined, but they are using different enumeration options? 


    Daniel Cai | http://danielcai.blogspot.com | Tata Solutions Inc.
    • Marked as answer by Goosey314159 Thursday, November 3, 2011 6:00 PM
    Wednesday, November 2, 2011 10:31 PM
  • Hi Daniel,

    First off thanks so much for digging into this.

     

    I think I'm starting to understand what's happening here.

     

    I do have 2 properties with the same name attached to different entities.

    1st is an optionset, which DOES have a generated enum and the other is a "Two Options" aka a Boolean, which I now realize the "generatepicklistenums" util only generates enums for picklists as the name painfully implies :) and not for any Boolean values.

     

    I believe the issue is that we're using that Boolean value to store non-bool data.

    So in code it's un-intuitive to say  MyLead.LeadType = true; // No one would know true means LeadA

    instead of it's (probably intended) usage MyLead.IsActive = true; // This is obvious and hence doesn't need an enum.

     

    Let me know your thoughts on this.

     

    Thanks again

    Jon


    Thursday, November 3, 2011 1:56 PM
  • I just verified that CrmSvcUtil doesn't generate enums for "Two Options" field. So you might want to change the field type to optionset if that's what you are pursuing. 
    Daniel Cai | http://danielcai.blogspot.com | Tata Solutions Inc.
    Thursday, November 3, 2011 6:38 PM