Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Trying to prevent duplicate users with same email address in my custom user table

Thomas Miles
Tera Contributor

I am writing a client script to stop a user from creating a new user record if the same address is in the system already

 

function onSubmit() {
    //Type appropriate comment here, and begin script below
    var currentEmail = g_form.getValue('email');
    
    var newUser = new GlideRecord('table_name');
    newUser.addQuery('email', currentEmail);
    newUser.query();
    if (newUser.next()) { 
        return false;
        
    }
}

5 REPLIES 5

Hajar BENJAHHAR
Mega Sage

Hello, 

No need to create a client script to verify if a user has the same email. 

You have only to check Unique for email field in User [sys_user] table. 

This will not let  to create two users with same email. 

 

find_real_file.png

i have my own custom user table will this option is not available in my scoped app

I believe you can still use this feature but may have to add it to your Dictionary Entry form for your custom field/table.

find_real_file.png

does it need to be added from the global side?