I need to populate the email address from the user table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2023 03:19 AM
I need to populate the email address in the custom table(u_test) from the sys_user table through the employee number as reference. Can anyone help me on the background or fix scripts to achieve the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2023 03:37 AM
In the above code just modify this line
customTableGR.getValue('employee_number');
With
customTableGR.getValue('GID');
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2023 03:48 AM
Hello @Archana23 ,
You can refer to the below code to set the email address on your custom table field referring from the sys_user table.
var test = new GlideRecord('u_test'); //your custom table
test.addEncodedQuery('u_employee_number!=NULL'); //use the backend value of the employee number field
test.query();
while (test.next()) {
var empNumber = test.getDisplayVale('u_employee_number');
var user = new GlideRecord('sys_user');
user.addQuery('employee_number', empNumber);
user.query();
if (user.next()) {
test.u_gid = user.email; //use the dot-walk to get the email of the user and set it in the 'GID'
test.update();
}
}
If the above solution resolve your issue, Please mark the solution as 'Accepted Solution' and also mark it as 'Helpful'.
Thank You!
Prathamesh.