Condition to check if string starts with numbers

Maria DeLaCruz
Tera Guru

Hello,

I need some help with a condition.   We have a notification on the sc_req_item record that needs to go out only if the requested_for.user_name starts with a number (0-9).   What's the best way to construct the condition?

Thanks,
Maria

4 REPLIES 4

Chuck Tomasi
Tera Patron

Hi Maria,



Where is this notification triggered from? Are you using the Record Updated or Inserted method or are you triggering from an event?



If the former (shown here), you're out of luck.


find_real_file.png



If you are triggering from an event (likely form a business rule) then you can have the business rule do the checking before firing the event.



Email Notifications - ServiceNow Wiki



You can tell really quickly by looking at that "When to send" tab on the notification Let me know.


Hi Chuck,



We are triggering the notification when record is inserted.  


Will an advanced condition work?



Maria


Are you talking about the advanced condition on the business rule or the notification? (screenshot please)


Hi,



First option , you can use the advance condition of notification and edit like below and it will send the notification.


var g1=current.getValue('your_field_name');


if(/^[0-9]/.test(g1)) // Regex


  {


  answer=true;


  }


else


  {


  answer=false;


  }


Second option, you can also use a BR to call an event and then using that event the notification will be triggered.



Thanks.



Hit Like/Helpful/Correct, if applicable.