How to create salesforce user (not `Account` record) through salesforce CLI

clisalesforcedx-cliuser-managementuser-record

I want to create a User through Salesforce CLI.

  • I know that I can create Scratch-Org users (DOC), but I want to create one in production organization;
  • I know that I can create user through API (DOC, DOC), but I don't want to use API(*1);
  • If it's not possible at all through one or more steps(*1) with CLI, then If you link the source of such claim, then it's the valid answer too;
  • Please do not confuse User with Account object;

*1 – If the solution to the problem is to create REST API access to SF through CLI and then create user through REST API, then it's also a valid answer, as long it does not require human interaction (i.e. copying API credentials from SF GUI – however it requires a user secret that have to be obtained through reset and email, for the first time…). I'm just mentioning it here because I have not figured it out yet myself.

Best Answer

It is possible to create user's account through CLI but it seems that there's no option to reset password. So the user will have to reset it manually.

To create user's account through CLI, use force:data:record:create command.

Example usage:

sfdx force:data:record:create -u YOURUSER -s User -v "Password=USER_PASSWORD Username=USER_EMAIL Alias=SOME_ALIAS LastName=USER_LAST_NAME FirstName=USER_FIRST_NAME CompanyName='USER_COMPANY' Country=USER_COUNTRY Email=USER_EMAIL CommunityNickname=USER_NICKNAME IsActive=true TimeZoneSidKey=America/Los_Angeles LocaleSidKey=en_US EmailEncodingKey=UTF-8 ProfileId=USER_PROFILE_ID LanguageLocaleKey=en_US"

Documentation: https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_data.htm#cli_reference_force_data_record_create

Related Topic