locked
How to create dynamic option lists in CRM 2011 RRS feed

  • Question

  • Hi,

    I have a new challenging requirement.

    I need to have  two optionsets. one with list of all entities. another with list of all attributes for the entity that is selected in first option list.

    How to create these option lists.

    we need to apply these option sets to two fields in our custom entity.

     

    I really appreciate your thoughts on this. Thanks.

    Friday, August 19, 2011 9:56 AM

Answers

  • There is one more solution.

    The two custom field on entity, make them text field instead of optionsets.

    Create a webresource with two drop down boxes. put that webresource in a iframe on your custom entity.

    On change event of the second drop down box  update the fields on the custom entity form.

     

    I hope this helps.

     


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    • Marked as answer by CSK.CRM Monday, August 22, 2011 4:52 AM
    Sunday, August 21, 2011 12:56 PM

All replies

  • You need to write your very own JScript to populate entities and then on change of first Option List execute second JScript to populate attributes from metadata. Your script need to prepare a fetchxml query based on  below SQL queries:

     

     

    SELECT	 DISTINCT a.Name, l.Label
    FROM	 MetadataSchema.Attribute a
    INNER JOIN	 MetadataSchema.Entity e
    ON a.EntityId = e.EntityId
    AND YEAR(e.OverwriteTime) = 1900
    INNER JOIN	 MetadataSchema.LocalizedLabel l
    ON a.AttributeId = l.ObjectId
    AND l.ObjectColumnName='DisplayName'
    AND l.LanguageId = 1033
    WHERE	 e.Name = 'opportunity'


    SELECT	 DISTINCT e.Name as Entity, a.Name as Attribute, pl.Value, l.Label
    FROM	 MetadataSchema.Attribute a
    INNER JOIN	MetadataSchema.Entity e
    ON a.EntityId = e.EntityId
    AND YEAR(e.OverwriteTime) = 1900
    INNER JOIN	MetadataSchema.AttributeTypes t
    ON a.AttributeTypeId = t.AttributeTypeId
    AND t.Description = 'picklist'
    INNER JOIN	MetadataSchema.AttributePicklistValue pl
    ON a.OptionSetId = pl.OptionSetId
    INNER JOIN	MetadataSchema.LocalizedLabel l
    ON pl.AttributePicklistValueId = l.ObjectId
    ORDER BY	e.Name, a.Name



    Ayaz Ahmad CRM Architect | http://ayazahmad.wordpress.com
    Friday, August 19, 2011 12:01 PM
    Moderator
  • Hi Ajay,

     

    I think JScript would be the only solution. however, I believe that the option lists needs to have to be selected dynamically. let see an ex:

    one option list with CRM and SharePoint values

    another option list with 1. Development, 2. customization , 3. administration, 4.designing values. 1 and 2 relates to CRM and 3,4 relates to SharePoint.

    now I can dynamically populate the values in the second optionlist based on the value selected in the first option list. this is possible because the values are already available in second option list.

    in my case, its little different in the first option list I need to populate all the existing entities and based on the entity selected I want to populate all its attributes in optionlist 2.

    I completely agree that I need to use Jscript for this. I also wanted to know whether optionlist facilitates my requirement.

     

    Please share your thoughts.

    Saturday, August 20, 2011 10:31 AM
  • There is one more solution.

    The two custom field on entity, make them text field instead of optionsets.

    Create a webresource with two drop down boxes. put that webresource in a iframe on your custom entity.

    On change event of the second drop down box  update the fields on the custom entity form.

     

    I hope this helps.

     


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    • Marked as answer by CSK.CRM Monday, August 22, 2011 4:52 AM
    Sunday, August 21, 2011 12:56 PM
  • Hi Amreek,

     

    I feel also the same and completely agree with you. I would try this out and let u guys know if I came up with any issues... thanks.

    • Marked as answer by CSK.CRM Monday, August 22, 2011 4:52 AM
    • Unmarked as answer by CSK.CRM Monday, August 22, 2011 4:52 AM
    Monday, August 22, 2011 4:51 AM