This content has been marked as final. Show 9 replies
Support have come back with the following which i wasnt aware could be done.
When using a CRM On Demand workflow, how do I make a field required upon population of another one? (Doc ID 743664.1)
They are now going to look to see if they can change the code to do the opposite.
For those of you unable to download the document from MetaLink3 here it is:
As an example to illustrate this requirement, let’s say that once there is a checkbox field called "My_Check_Box". When this field is checked, the "Account Type" field need to become a required for entry by the user. To do this follow these steps:
1. In the Admin> Application Customization, select the appropriate Object and go into the Object Field Setup.
2. Edit the field called "My_Check_Box" and enter a Field Validation expression so it uses the following expression:
=[<bMy_Check_Box_ITAG>] AND NOT([<AccountType>] IS NULL AND [<bMy_Check_Box_ITAG >]='Y')
3. Enter an explicit error message.
This expression means that when the checkbox field is checked, the Account Type becomes required. Your custom error message will be raised when checking the checkbox, leaving the account type unpopulated and trying to save the account record.
4. Edit the Account Type field and enter the following expression as Field Validation:
=[<AccountType>] AND NOT([<AccountType>] IS NULL AND [<bMy_Check_Box_ITAG >]='Y')
5. Enter an explicit error message.
That validation handles the user case where a user changes the Account Type value from a NOT NULL value to a NULL value. Your custom error message will be raised when emptying out the account type from a populated value to nothing while the checkbox is checked and trying to save the account record.
Note that the expression in both fields validations begins with the field variable on which the statement is being written.**
So I know this post has been around for a while, however, I have a potential solution that might be useful for people looking to do something similar.
It is similar to the feedback provided by Oracle concerning a field vlaidation, but with a slight change. I was trying to make a picklist value read-only when another picklist value was not null, however, the solution should also be able to be applied to other field types.
Try something similar to: NOT(PRE('<Picklist01_ITAG>') <> [<Picklist01_ITAG>] AND [<Picklist02_ITAG>] IS NOT NULL))
For a text field being read-only it would be something like: NOT(PRE('<Textfield01_ITAG>') <> [<Textfield01_ITAG>] AND [<Picklist_ITAG>] IS NOT NULL))
This essentially means that when Picklist02 is not null, the field that we want to be read only cannot be saved as anything other than what was previously in that field, whether that be a value or blank. It alos allows you to provide an error message explaining why such a change cannot be made.
Hope this helps and/or makes sense for those looking to make this change in the future!
Note: For those trying to use a workflow to enforce this, workflows aren't always desirable because they allow the user to change a value and then it gets removed without providing an explanation - in other words it is frustrating and confusing for the end user. Just something to keep in mind.