How to change visibility of other fields based on the value of "CostCenter" in Sales Order

Hi all,

I have added two new fields to the sales order.

I need to make these two fields visible or not based on the value of the CostCenter in the financial dimension.


My previous approach to implementing similar functions was to change the “visible” properties of other controls in the “modified” method of form controls.

However, the fields in the financial dimension seem to be dynamically rendered, and I don’t seem to be able to extend the “modified” method of CostCenter directly.

I’m not sure if there are any other methods to meet this requirement.

You can check the value of dimension in active method of the data source & based on that you can make it visible or not. Active method is called when you open the form, change record, refresh the record or page, etc.

Hello @Krupa ,

This seems like a feasible solution, but I have a new problem:

I don’t know which field value I need to check in the Active method. Because I don’t know which data source the “CostCenter” field is in. :smiling_face_with_tear:

I checked all the data sources of the sales order form, but I didn’t find any field named “CostCenter”.

@Dalux_Chen, see if the below link helps. CostCenter is not a value stored on the sales order. It is part of the financial dimension. It is converted to specific dimension format & stored in a different table. You need to extract value of specific dimension from that. Below link has sample code for it.

Thank you very much for your suggestion @Krupa

Despite encountering some setbacks, I ultimately fulfilled the requirement. The method you provided is indeed feasible.

However, the “active” method will only be called when I click the “save” button, which means that if I check the value of CostCenter in the “active” method, I need to click save first before I can change the visibility of “Vessel” and “Voyage”.

If there were any means to change the visibility of “Vessel” and “Voyage” immediately after modifying the value of “CostCenter” without clicking the “Save” button, that would be even better.

You can write same code in modified method of the data source fields along with active method. It is required in active method, so that if you open an old record, the fields will remain disabled based on the call center value.

Thank you again for your help !

But in this case, I will run into this problem again: I don’t know which field I should write the ‘modified’ method for. :joy: The CostCenter field is not in the form.

Dynamics 365 development is so complex.