Posted by John Clifton | November 14, 2014
Business Rules for CRM 2013 prove, yet again, to be a great feature. Although you can perform several actions on a form using Business Rules, when you use the ‘Set Field Value’ option there is no ability to directly remove a value from a field. You can set the value to ‘something’ but not to null or blank- which we know is a frequent request and usually handled with JScript.
In most cases you can work around this limitation by creating a ‘dummy’ field of the same field type and properties as the field you want to clear out and then using it in the ‘Set field value’ action.
As an example, let’s say we are entering data into a custom entity called ‘Events’. If the ‘Type of Event’ field is set to ‘Physicians Dinner’ we might use Business Rules to expose a ‘Dinner Type’ field and require the user to make a selection:
However, if the ‘Type of Event’ is changed later, we need to clear out the ‘Dinner Type’ value since it is no longer relevant. In order to do that we would create a new option set field (remembering to not add any values to the option set), add the field to the form (fields used in Business Rules must be on the form) and uncheck the ‘Visible by default’ checkbox.
Then you construct a Business Rule that clears out the value of the ‘Dinner Type’ field by setting it to the value of the ‘Dummy Dinner Type’ field when the appropriate conditions exist
Note that this does not work for lookup fields . . . if your ‘dummy’ field is able to have a value of ‘blank’ or null, this trick should work.
If you have any Questions or Comments, we’d love to hear from you! Please don’t hesitate to contact us.