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
tocktock 

Create Salesforce users from external webpage

Hello,
    I'm trying to create a basic 'user' on salesforce, from a remote website using PHP and the partner.wsdl. I can create accounts, leads etc..  but when I try to create a user, it doesn't error and also doesn't work! 
 
I'm just trying to set these fields to start with, to get going: 
  • FirstName
  • LastName
  • Phone
  • Email

I presume this can be done? are there any fields that I have to set that I'm not?

cheers.

ClaiborneClaiborne
I don't think the "create user" function is exposed in the api. All users have to be created within the regular salesforce.com interface. Once a user is created, you can update various user fields and retrieve user information. But you can't create.
SuperfellSuperfell
Sure you can, you just need to specify all the required fields on the User object (including things like timezoneSidKey, languageLocaleKey, LocaleSidKey etc), a tool like AppExchange Explorer, SoqlXplorer or the Developers Sidekick can help you examine the schema info returned by the describe calls which include things like the valid set of picklist values for those locale fields.
SuperfellSuperfell
Also in the "it doesn't error and doesn't work" phase, make sure you're checking the returned SaveResult structure for any problems with trying to create that record.
tocktock

 Thanks,  I have it working when I set the following fields. 

   'Username'                 
   'EmailEncodingKey'     
   'LocaleSidKey'               
   'FirstName'                
   'LastName'                
   'Phone'                     
   'Email'                        
   'IsActive' 

 'ProfileId'                    => must be set
  'Alias'                         => must be set and unique               

 

  • Is there a function on the API that generates the 'Alias' field value on the fly?
  • Also is there a way to set the new user's password to a default value for the first time they log into salesforce?

Cheers.

tocktock
I've discovered the setPassword API call, so ignore the password question.
 
But, if there's an API call that generates the 'Alias' field value on the fly it would be very helpful?
 
cheers