It connects a Silverstripe Install to a Sales Force account using the Partner "approach".
- add your wsdl file to your mysite folder and make sure it is protected, see below
- add to Silverstripe install as per usual
- see:
salesforcepartner/_config/salesforceconfig.yml.example
and implement in mysite as you see fit. You will definitely need to set the login credentials
The same as you use for logging in to the online CMS for Sales Force
Login to Sales Force CMS and follow these instructions https://webkul.com/blog/security-token-salesforce/
Please visit code/Api/Contact
folder to see the public methods that will be of use to you.
You should set up dataobjects / pages with the following methods:
/**
* @var array
*/
private static $many_many = [
'SalesforceDefaultCreateContactFields' => 'SalesforceDefaultContactField',
'SalesforceDefaultUpdateContactFields' => 'SalesforceDefaultContactField',
'SalesforceDefaultContactFilters' => 'SalesforceDefaultContactField',
];
/**
* @return FieldList
*/
public function getCMSFields()
{
$fields = parent::getCMSFields();
$this->setDefaultFieldsForSalesforce();
$fields->addFieldsToTab(
'Root.SalesforceSettings',
MySalesforceContactConfigApiFormFields::all_fields(
$this,
'SalesforceDefaultCreateContactFields',
'SalesforceDefaultUpdateContactFields',
'SalesforceDefaultContactFilters'
)
);
return $fields;
}
public function setDefaultFieldsForSalesforce()
{
MySalesforceContactConfigApi::add_fields_to_send_on_creation(
$this->SalesforceDefaultCreateContactFields()
);
MySalesforceContactConfigApi::add_fields_to_send_on_update(
$this->SalesforceDefaultUpdateContactFields()
);
MySalesforceContactConfigApi::add_fields_to_use_for_filter(
$this->SalesforceDefaultContactFilters()
);
}
set up controller with the following form (you will have to make your own Form, as you see see fit):
/**
* @return mixed
*/
public function MySalesforceForm()
{
$this->setDefaultFieldsForSalesforce();
$form = new MySalesforceForm($this);
return $form;
}
In the MySalesforceForm
form, add the following (this will be called on "saving" / "actioning" you form (saving the results of the form):
public function sendToSalesforce(
$email, $phoneNumber = '', $firstName = '', $lastName = '', $extraFields = [], $extraFilterFields = []
) {
if (MySalesforceContactApi::is_email_registered($email, $extraFilterFields)) {
//update
$success = MySalesforceContactApi::update_email_subscriber(
$email,
$extraFields,
$extraFilterFields
);
} else {
//add
$success = MySalesforceContactApi::add_email_subscriber(
$email,
$phoneNumber,
$firstName,
$lastName,
$extraFields,
$extraFilterFields
);
}
return $success;
}
This folder is automagically created by the uuf6429/force.com-toolkit-for-php
vendor package. You can set the details in composer.json.
changed due to double class names (both lowercase and upper case existed):
- describeApprovalLayoutDouble
- describeGlobalThemeDouble.php
- describeLayoutDouble.php
code/SForce/SforceService.php