You need to sign in to do that
Don't have an account?
Claire Nicolay
REGEX in Workflow rule
Hi, I have a validation rule for the phone number to be 10 characters as follows xx xx xx xx xx
To make things quicker and easier for the users, I would like to replace my validation rule by a workflow rule, so I defined that, if the field "MobilePhone", which is phone format, is not empty, then the field should be updated using the following formula:
REGEX( MobilePhone , "[0-9]{2} [0-9]{2} [0-9]{2} [0-9]{2} [0-9]{2}")
I get the following error message: formula result is data type(Boolean) not compatible with the expected data type (Texte)
Can somebody help to make this worklfow field update work? Thanks!
To make things quicker and easier for the users, I would like to replace my validation rule by a workflow rule, so I defined that, if the field "MobilePhone", which is phone format, is not empty, then the field should be updated using the following formula:
REGEX( MobilePhone , "[0-9]{2} [0-9]{2} [0-9]{2} [0-9]{2} [0-9]{2}")
I get the following error message: formula result is data type(Boolean) not compatible with the expected data type (Texte)
Can somebody help to make this worklfow field update work? Thanks!
You cannot update a MobilePhone field through REGEX() function as REGEX returns a boolean value either TRUE or FALSE.
Syntax: REGEX(Text, RegEx_Text)
Returns TRUE if Text matches the regular expression RegEx_Text. Otherwise, it returns FALSE.
Hence the error, because its expecting to return some text, but its getting a boolean value(i.e either True or False)
Your best bet is using a validation rule for this as you were using it earlier, but if you want to format the mobilephone field automatically then you'll have to write an apex trigger.
Hope this helps!
Thanks,
Apoorv
All Answers
You cannot update a MobilePhone field through REGEX() function as REGEX returns a boolean value either TRUE or FALSE.
Syntax: REGEX(Text, RegEx_Text)
Returns TRUE if Text matches the regular expression RegEx_Text. Otherwise, it returns FALSE.
Hence the error, because its expecting to return some text, but its getting a boolean value(i.e either True or False)
Your best bet is using a validation rule for this as you were using it earlier, but if you want to format the mobilephone field automatically then you'll have to write an apex trigger.
Hope this helps!
Thanks,
Apoorv
Was hoping there is a solution using a WF and field update to ensure the phone number looks as follows : 11 11 11 11 11
Try using this formula in your workflow field update action :
MID(TEXT(VALUE(Phone)),1,2)
+' '+MID(TEXT(VALUE(Phone)),3,2)
+' '+MID(TEXT(VALUE(Phone)),5,2)
+' '+MID(TEXT(VALUE(Phone)),7,2)
+' '+MID(TEXT(VALUE(Phone)),9,2)
Hope this helps!
Please let me know how this works for you, mark this as Solved if this helps you so that others can view it as a proper solution.
Thanks,
Apoorv