Help on replacing the values through Business rules
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
HI All
I will get an value in the last logged in user field in computer table I need to trim that and need to check the same in user_id in the user table. Example value is: abc@example.com. ABC is the user id value or RF ID in user table.
If the value is not present in user_id then I need to check RF ID value in user table. Now my requirement is if the value is not present/unavailable in the user table in both user_id and RF ID I need to clear the value from most frequent logged in user in computer table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
37m ago
share what script you tried and what's not working?
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
27m ago
Try this code snippet from BR. It will work. Update query with correct field name as per your instance.
var loggedinUserEmail = current.u_logged_in_user;
var loggedinUserEmailSplit = loggedinUserEmail.split('@');
var loggedinUserEmailSplitb4atDrate = loggedinUserEmailSplit[0] + '@example.com';
var loggedinUserEmailSplitb4atDrate1 = loggedinUserEmailSplit[0] + '@example.'; // sometime co.in is also there, avoid it if you dont have these kind of data
var userGr = new GlideRecord('sys_user');
userGr.addEncodedQuery('email=' + loggedinUserEmail + '^ORuser_idSTARTSWITH' + loggedinUserEmailSplitb4atDrate + '^ORuser_idSTARTSWITH' + loggedinUserEmailSplitb4atDrate1 + '^ORu_rf_id=' + loggedinUserEmailSplitb4atDrate + '^ORu_rf_id=' + loggedinUserEmailSplitb4atDrate1 );
userGr.orderByDesc('sys_created_on');
userGr.query();
if (userGr.next()) {
current.user = userGr.sys_id.toString();
}
