Access filed form related entity on Dynamics Form using JavaScript

With the new Dynamics 365 UCI and tabs it can be a more involved to access columns (fields) as you have to access them through Controls.

Some developers have been having trouble with the new Field Service "Bookable Resource Booking" form which also has the Work Order table (entity) built into it.
In this scenario we want to access the custom column "Fault Category" which is part of the WorkOrder table.

If you go into the Controls for the "Booking and Work Order" form Field Service you will notice that it use QuickForms:

To access the "Fault Category" column attribute on the Service tab we need to get the:

  • tabs
  • sections
  • control

So in our javascript to get the value of our Choice (optionset) column we would use:

var info = formContext.ui.tabs.get(3).sections.get(0).controls.get(0).getAttribute("test_faultcategory").getValue();

You can use the console to work out the names or index to use.

To find the names or index open Developer console in EDGE with F12

Run your script which has formContext and set a debug point or enter debugger; in your script.

Once you have loaded formContext then go to the Console and run these lines

To get Tab: formContext.ui.tabs.get()


To get Section: formContext.ui.tabs.get(3).sections.get(0) we can use the index i.e. 3 or the name 'fstab_service'

To get Control: formContext.ui.tabs.get(3).sections.get(0).controls.get()

We can then use:
var info = formContext.ui.tabs.get(3).sections.get(0).controls.get(0).getAttribute("test_faultcategory").getValue();
This gives us the value of Fault Category 100000026
workorder in Field Service
Hope this helps troubleshoot accessing attributes on new Forms.

Leave a Reply

Your email address will not be published. Required fields are marked *