map validation_rule.validate_mobile_number1(String crmAPIRequest)
{
/* The snippet below shows you how to get a list of fields, their values from a MAP object. The fields’ values can be obtained from the same MAP object. */
entityMap = crmAPIRequest.toMap().get("record");
/* The example below demonstrates how a field’s value (email) can be obtained from a MAP object. Here, entityMap - Map Object, Email - Field's API name
Sample entityMap= {'Email': 'xxx@xxx.com', 'Last_Name': 'xxx'}; */
email = entityMap.get("Email");
response = Map();
Mobile = ifNull(entityMap.get("Mobile"),"");
if(Mobile == "")
{
response.put('status','error');
response.put('message','Please Enter a Mobile Number.');
}
else
{
retValue = matches(Mobile,"^\+[1-9]\d{1,14}$");
if(retValue == true)
{
response.put('status','success');
}
else
{
response.put('status','error');
response.put('message','Please Enter a Valid Mobile Number in E.164 Format (e.g., +9715xxxxxx92)');
}
}
return response;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter