Report to find all Users that where the User ID is different from their Email Address
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 11:33 AM
On our sys_user table, the User ID field is a string field that is essentially the same as the Email field which is an email field type.
I am trying to create a report that will show me all users where the User ID is different from Email but because the email field is not a string field it doesn't allow you to compare those two fields.
I created this function: "Email String": glidefunction:concat(email) into a text field on the report. This works if you are just trying to run a report and want that field as a string value in your export/view. However when I update the condition: User ID is different from Email String, it returns a blank report - which I'm sure is because it's just a function field and not necessarily a column that stores data.
Can I convert the function field into an actual value stored field? Should I have some type of script created that will update the "Email String" field with the value that is in the "Email" field? Trying to find the best practice on what other users have tried but wasn't coming up with anything similar to my scenario. Any help would be greatly appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 06:07 AM
We are facing the same issue. Have you had any luck in resolving this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 06:36 AM
No unfortunately, I have not been able to resolve this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 06:37 AM
You can use the following script, run in Scripts - Background.
var users = new GlideRecord('sys_user');
users.addQuery('active', true);
users.query();
while (users.next()) {
var emailStr = users.email.toString();
if (users.user_name != emailStr) {
gs.info("userid: " + users.user_name + " does not match email: " + emailStr);
users.user_name = emailStr;
// users.update();
}
}
Un-comment the line that updates the record when ready.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 07:23 AM
@Bert_c1 - Thank you. This worked perfectly for us.