- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 12:06 PM
I need to write a BR that checks if there is a value in the User ID [user_id] field in the Email [sys_email] record. If there is no value in the field, then move forward with the check. I have this portion ready.
In the Email [sys_email] record, I need to use the User [user] field and search the following fields on the User [sys_user] table:
Email [email]
Email 2 [u_email_2]
If there is a match found, then I need to set the value of the Email [sys_email] record's User ID [user_id] field to the Sys ID of the located record in the search from the User [sys_user] table. Any ideas on how to write this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 01:28 PM
I ended up going with this and it looks like testing is going well:
(function executeRule(current, previous /*null when async*/) {
var grSysUser = new GlideRecord('sys_user');
grSysUser.addQuery('email', current.user).addOrCondition('u_email_2', current.user);
grSysUser.query();
if (grSysUser.next()){
current.user_id = grSysUser.sys_id;
}
})(current, previous);
Just adding in case anyone finds helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 12:26 PM
Hi,
The user_id value will appear only if User[user] field is not empty, you can easily dot walk the user_id and get the email.
May i know what are you trying to achieve here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 01:28 PM
I ended up going with this and it looks like testing is going well:
(function executeRule(current, previous /*null when async*/) {
var grSysUser = new GlideRecord('sys_user');
grSysUser.addQuery('email', current.user).addOrCondition('u_email_2', current.user);
grSysUser.query();
if (grSysUser.next()){
current.user_id = grSysUser.sys_id;
}
})(current, previous);
Just adding in case anyone finds helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 11:43 PM
I found the real-world examples provided in this post to be particularly useful in understanding the concepts discussed. click here