Autopopulate logged in user's email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 12:39 AM
Hi,
I am trying to autopopulate the logged in user's email using business rule. It's not working. Kindly help.
(function executeRule(current, previous /*null when async*/ ) {
current.email = gs.getUser().email;
})(current, previous);
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 01:21 AM
Hi @Anand Kumar P,
This is working on the description field. How do I make it for the email field? It isn't plain text field.
(function executeRule(current, previous /*null when async*/ ) {
current.description = gs.getUser().email;
current.caller_id.email = gs.getUser().email;
current.caller_id.email = gs.getUser().getEmail();
})(current, previous);
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 01:31 AM
Hello @Community Alums ,
You can follow the below script in your BR, I have checked this script in my PDI it is working fine.
(function executeRule(current, previous /*null when async*/) {
var curUser = gs.getUserID();
var user = new GlideRecord("sys_user");
user.addQuery("sys_id",curUser);
user.query();
if(user.next()){
gs.log("Loggedin User Email is "+user.email);
current.email=user.email;
}
})(current, previous);
Please mark my answer as accepted solution and give thumbs up, if it helps you.
Regards,
Abhishek Thakur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 01:51 AM
Hi @Abhishek_Thakur,
That didn't work for me. Before posting it in the community, I exactly used it.
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 01:54 AM
Hello @Community Alums ,
Then I would recommend using the display business rule along with the scratch pad that will help to bring the email id from server to client. So, that you can set that value in your form.
Please mark my solution as accepted and give thumbs up, if it helps you.
Regards,
Abhishek Thakur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 01:58 AM