function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
krish_krish_ 

Global Function to check the Salesforce Username...

Hi to all,
I want to create user in my organisation through code using contact record values.
I use the User's Username as contact Email Field.

How do I check the Email id is not repeated in whole salesforce DB???
Is there any global functions are there???
Send me the sample code...

Thanks,
Krish.
Sam.arjSam.arj

Use SOQL in your code.

 

 

Lisr<User> users = [SELECT id, name FROM User WHERE username = :email];

 

 

 

krish_krish_

The above SOQL query is retrived only for the my Organisation user's only.

I want to check the whole Salesforce user names..

How to write the SOQL query to check the user's  username on salesforce DB???

 

Thanks,

Krish.

 

MyAwesomeAliasMyAwesomeAlias

I believe you are going to have to try to create the user and then catch the exception in the event that the username already exists.

Devendra SawantDevendra Sawant

how i can populate roles from my organisation??

can you provide me code for it??

geetgeet
Hi krish,
have u succeeded in querying the entire salesforce database?

Thanks,
geet.
 
Genesis Ortega 6Genesis Ortega 6

Hi Everyone,

I've reached out to salesforce related to this issue and confirmed that there are no workaround to check where the username exist across different salesforce org the user has.

The only way is to contact salesforce support as part of the Salesforce security protocols.

Hope this helps.

Regards,
Gen