Search code examples
dynamics-crm-2011dynamics-crmdynamics-crm-2013dynamics-crm-2015

Ms Dynamics CRM custom workflow get visible attributes from form using c#


How to get visible attributes from entity form using c# in custom workflow? Any idea please share!


Solution

  • It's a PITA but it's doable.

    1. retrieve the form you want to process from the systemform entity (you want the formxml attribute)
    2. the formxml attribute contains the form definition, it's encoded (< is written as &lt; and so on) xml format.

    Inside the formxml contents, a field looks like this:

        <cell id="(guid)" labelid="(guid)" showlabel="true" locklevel="0" visible="false">
        <labels>
            <label description="(field label)" languagecode="1033" />
        </labels>
        <control id="(field name)" classid="(guid)" datafieldname="(field name)" disabled="false">
    
    1. parse the xml, looking for cell elements which do not have visible attribute (it's only there if the field is hidden)
    2. you might have to narrow the list down through further searches in xml (not 100% positive about what i.e. a subgrid would look like) but I have no direct experience with this kind of logic so I can't pinpoint each and every corner case

    Pain point: You won't be able to tell if a field visibility has been toggled through javascript