Populate/Display the user's name

ElvinSalim
Tera Contributor

When a user has checked the "Follow" checkbox, then displays the user's name in the "Follow by" field. The BR script is not working, do I need other script/logic or just modify it?

 

(function executeRule(current, previous) {
if (current.u_follow == true) {
var user = gs.getUser(); 
current.u_follow_by = gs.getUserDisplayName();
}
})(current, previous);

2 ACCEPTED SOLUTIONS

Harish KM
Kilo Patron
Kilo Patron

you could just do this

current.u_followed_by = gs.getUser().getDisplayName();

Regards
Harish

View solution in original post

Just copy and paste this script and check if it displays the name. I believe it should
One more best practice would be - Transfer the if condition in the "When to run" section of Business rule

(function executeRule(current, previous) {
if (current.u_follow == true) {
        var user = gs.getUserID();
        current.u_follow_by = user;
    }
})(current, previous);

View solution in original post

12 REPLIES 12

Harish KM
Kilo Patron
Kilo Patron

you could just do this

current.u_followed_by = gs.getUser().getDisplayName();

Regards
Harish

Ashutosh C J
Tera Guru

Hi ElvinSalim,
Try this 
current.u_follow_by = gs.getUser().getFullName();

You can even write code like this:

(function executeRule(current, previous) {
if (current.u_follow) {
var user = gs.getUser(); 
current.u_follow_by = user.getFullName();
}
})(current, previous);

Please mark helpful 🙂

Hi @Ashutosh C J 

It still doesn't work, probably because of the field configuration? "Follow by" is reference to user and read only.

Ahh I see
Then just add current.u_follow_by = gs.getUserID();