How to get visible attributes from entity form using c# in custom workflow? Any idea please share!
-
What are you trying to accomplish ? Processes aren't supposed to care about forms (since the data might not come from a form) – Alex Sep 15 '15 at 08:01
-
means process doesn't read the form data – Bilal Islam Sep 15 '15 at 08:09
2 Answers
It's a PITA but it's doable.
- retrieve the form you want to process from the
systemform
entity (you want theformxml
attribute) - the
formxml
attribute contains the form definition, it's encoded (<
is written as<
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">
- parse the xml, looking for
cell
elements which do not havevisible
attribute (it's only there if the field is hidden) - 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

- 23,004
- 4
- 39
- 73
-
Of course, processes should *never* assume data is coming in from a form (what if an external application creates/updates a record ? imports ? other workflows manipulating data ? plugins ? external applications ? ) so YMMV – Alex Sep 15 '15 at 08:42
What do you mean visible attributes? You mean attributes with a value or attributes showed in the form? If it's the second the only way that you have to keep track of that is use a text field and use some code to identify what is active.
ex. create a text field
and write in it all the fields that are visible ex name and surname:
"name","surname"
You can manipulate this with javascript and business rules to keep the list of fields updated at every time for each record. In the code behind you just need to read for the text field and manipulate the magic string. It's not a really nice operation, but is the only way i can see to keep track of what fields are shown on the form.

- 1,146
- 6
- 16