Set Default Price List field on Product as Read-Only in Dynamics CRM

By | January 24, 2017

Introduction:

In Dynamics CRM/365, we set the Default Price List on Product to define the calculation for Pricing that needs to be applied to the respective product. So there could be a business case where we may need to disallow a user from editing the default price list on the product.

The First Solution:

We can achieve this by making the Default Price List on Product as Read-Only through customizations by using Field Properties or by creating a Business Rule.

As you can see in the below screenshot, this solution doesn’t work.

Set Default Price List field on Product as Read-Only in Dynamics CRM

The field “Default Price List” is not locked

Set Default Price List field on Product as Read-Only in Dynamics CRM

The Second Solution:

The alternative way to make this field as “Read-Only” is to write a script which would make it read-only. And call this on “OnLoad” event of the Product form.

Below is the code snippet.

Xrm.Page.ui.controls.get(“pricelevelid”).setDisabled (true);

As you can see in the screenshot, we have created a JavaScript web resource and called a function to lock the field.

Set Default Price List field on Product as Read-Only in Dynamics CRM

Now it works and the field “Default Price List” is locked and is read-only.

Set Default Price List field on Product as Read-Only in Dynamics CRM

Conclusion: We cannot make the field “default Price List” on Product as Read-Only by setting it as Read-Only through field customizations. So the alternative way is to write a JavaScript code to make it Read-Only.

Wait no more! Gamification now available for Dynamics CRM On-Prem & Partner-Hosted Customers – Try Today!