The CreatorCon Call for Content is officially open! Get started here.

Report to find all Users that where the User ID is different from their Email Address

K Rice
Tera Contributor

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!

 

4 REPLIES 4

Melissa Berry
Tera Guru

@K Rice,

We are facing the same issue. Have you had any luck in resolving this?

No unfortunately, I have not been able to resolve this.

Bert_c1
Kilo Patron

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.

Melissa Berry
Tera Guru

@Bert_c1  - Thank you. This worked perfectly for us.