This is a discussion on creating a self service user within the Salesforce Coding Discussions forums, part of the Salesforce category; Hi there
Any idea why this code doesn't actually make a self
-
creating a self service user
Hi there
Any idea why this code doesn't actually make a self service user?
I have a lot more than 50 users to add and wanted to do it programmatically....but no joy!!
thanks
tammy
$query="select Id,email,firstname,lastname,username__c,password__ c from Contact where contacts_id__c='20856'";
$response=$conn->query($query);
foreach ($response->records as $result)
{
$id=$result->Id;
echo "id is ".$id."<br>";
$firstname=$result->fields->FirstName;
$lastname=$result->fields->LastName;
echo "name is ".$firstname." ".$lastname."<br>";
$username=$result->fields->Username__c;
$password=$result->fields->Password__c;
echo "u and p are ".$username." ".$password."<br>";
$email=$result->fields->Email;
echo "email is ".$email."<br>";
$updateFields = array(
'IsActive'=>1,
'Username'=>$username,
'FirstName'=>$firstname,
'LastName'=>$lastname,
'Email'=>$email,
'ContactId'=>$id,
'LanguageLocaleKey'=>'en_CA',
'LocaleSidKey'=>'en_CA',
'TimeZoneSidKey'=>'America/New_York'
);
$sObjectCustom = new SObject();
$sObjectCustom->type = 'SelfServiceUser';
$sObjectCustom->fields = $updateFields;
$createResponse = $conn->update(array($sObjectCustom));
}
-
Hi Tammy,
Here are my fields that successfully worked.
$formData[LastName]=$user->LastName;
$formData[FirstName]=$user->FirstName ;
$formData[Name]="$user->FirstName $user->LastName";
$formData[Username]=$user->Email;
$formData[Email]=$user->Email;
$formData[IsActive]='true';
$formData[ContactId]=$user->Id;
$formData[TimeZoneSidKey]='Pacific/Pago_Pago';
$formData[LocaleSidKey]='en_AU';
$formData[LanguageLocaleKey]='en_US';
With the object:
$objectData[objType]='SelfServiceUser';
Try active = "true"
Apart from that your fields and values look good.
Please post your response "print_r($response)" here so i can see the error messgae
Thx
Adam.
Similar Threads
-
By benbac in forum Salesforce APEX
Replies: 0
Last Post: 01-21-2011, 08:18 PM
-
By lucasvm in forum Salesforce Coding Discussions
Replies: 1
Last Post: 01-15-2009, 09:27 PM
-
By barrylast in forum Salesforce Coding Discussions
Replies: 3
Last Post: 11-30-2008, 03:08 PM
-
Replies: 0
Last Post: 05-24-2008, 05:43 PM
-
By mike in forum Salesforce Coding Discussions
Replies: 0
Last Post: 09-21-2007, 09:48 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
Bookmarks