How to tag a user in work votes via business rule

e_wilber
Tera Guru

How do you tag a specific user via a business rule when you update the work notes field? Simply hard coding @full_name wouldn't work if there are multiple users with the same name. You can't @ their email address or user ID either.

2 REPLIES 2

vaishali231
Giga Guru

hey @e_wilber 

 

In ServiceNow, @mentions don’t work using names, emails, or sys_ids directly. That’s why hard-coding @Full Name fails when multiple users share the same name, and using email or user ID doesn’t trigger a mention.


Tag the Assigned to user when updating work notes.

Business rule :

(function executeRule(current, previous) {

    if (!current.assigned_to.nil()) {
        var userSysId = current.assigned_to.toString();

        current.work_notes =
            "Please review this update " +
            "@[sys_user:" + userSysId + "]";
    }

})();


*************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.

Regards
Vaishali Singh

Chaitanya ILCR
Mega Patron

Hi @e_wilber ,

 

here is how to do it

you can replace the gs.getUserID() with target user's sysid and gs.getUserDisplayName() with displayName of the target user and 

'@['+gs.getUserID()+':'+gs.getUserDisplayName()+']'

 

ChaitanyaILCR_0-1768924926451.png

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya