Question Status

Suggested Answer
nagarajan jayaraman asked a question on 24 Mar 2015 11:01 PM

Hi All,

can i use locking fields for JavaScript

Nagarajan

Reply
Suggested Answer
Mithilesh Kumar responded on 24 Mar 2015 11:03 PM

Hi Nagarajan,

Since you are on CRM 2015, you can use Business Rule to Lock/Unlock your Fields.

Thanks

Reply
nagarajan jayaraman responded on 24 Mar 2015 11:09 PM

Thanks Mithilesh.

Reply
nagarajan jayaraman responded on 25 Mar 2015 4:21 AM

from past experience business rule not suitable all client side validation. because it's not related to event. so we go for javascript only for client side validation. is it correct?

Reply
Aileen Gusni responded on 26 Mar 2015 9:49 AM

Nagarajan,

Business Rules only run in onload and onchange (by user) event by default.

So if the value changed by another business rule it is possible not to trigger that.

You read this one:

https://technet.microsoft.com/en-us/library/dn531086.aspx

Especially:

Limitations for business rules

Business rules are intended to address common actions. Compared to what a developer can do by using form scripts, business rules have limitations. However, business rules are not intended to replace form scripts.

Here are a few limitations to using business rules:

  • Business rules run only when the form loads and when field values change. They do not run when a record is saved, unless the scope for the rule is set at an entity level.
  • Business rules work only with fields. If you need to interact with other visible elements, such as tabs and sections, within the form you need use form scripts.
  • When you set a field value by using a business rule, any OnChange event handlers for that field will not run. This is to reduce the potential for a circular reference, which could lead to an infinite loop.
  • If a business rule references a field that is not present on a form, the rule will simply not run. There will be no error message.
  • Whole Number fields that use the formats for TimeZone, Duration, or Language will not appear in the rule editor for the conditions or actions, so they cannot be used with business rules.
  • For Microsoft Dynamics CRM for tablets, the definition of the business rules are downloaded and cached when CRM for tablets opens. Changes made to business rules are not applied until CRM for tablets is closed and re-opened.
  • When you set the value of a lookup field, the text of the primary field value that is set in the form will always match the text that is visible in the rule definition. If the text representing the primary field value of the record you are setting in the lookup changes, the value set by your rule will continue to use the text portion of the primary field value defined by the rule. To fix this, update the rule definition to use the current primary name field value.

 

So that if you only have few validation and not complex it's very recommended using Business Rules because very easy but if very complex and you need to hide another component other than just a field then definitely Business Rules is not your choice.

 

Thank you.

Reply
Mithilesh Kumar responded on 26 Mar 2015 11:16 AM

Hi Nagarajan,

Business Rules have limited actions which can be performed. Also they can only be triggered on the OnLoad, OnSave event of the form and OnChange event of the field which limits the usage.

If you want to know about Business Rules you may wish to read this fantastic article

http://www.mohamedibrahim.net/blog/2013/10/08/business-rules-in-microsoft-dynamics-crm-2013-new-feature-introduction-basic-facts/

https://crmbusiness.wordpress.com/2014/10/20/crm-2013-understanding-business-rules/

Hope that helps

Thanks

For anything other than the above mentioned scenario,

Reply
Suggested Answer
Wes Danhof responded on 26 Mar 2015 11:58 AM

Yes you can lock fields with JavaScript, you could do something similar to:

var control = Xrm.Page.ui.controls.get("fieldname");

if (control != null)

{

   control.setDisabled(false);

}

Reply
nagarajan jayaraman responded on 26 Mar 2015 11:35 PM

Thanks Aileen!

Reply
nagarajan jayaraman responded on 26 Mar 2015 11:35 PM

Thanks Mithilesh!

Reply
nagarajan jayaraman responded on 26 Mar 2015 11:36 PM

Thanks Danhof

Reply
Suggested Answer
Mithilesh Kumar responded on 24 Mar 2015 11:03 PM

Hi Nagarajan,

Since you are on CRM 2015, you can use Business Rule to Lock/Unlock your Fields.

Thanks

Reply
Suggested Answer
Wes Danhof responded on 26 Mar 2015 11:58 AM

Yes you can lock fields with JavaScript, you could do something similar to:

var control = Xrm.Page.ui.controls.get("fieldname");

if (control != null)

{

   control.setDisabled(false);

}

Reply