Salesforce Integration not creating opportunity #6641
Unanswered
bentiffin
asked this question in
Developer Q&A
Replies: 1 comment
-
@bentiffin does the opportunity get created without using the filter? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working to connect donations forms with Salesforce. They include some custom fields. I'm using GiveWP with add-ons Recurring Donations and Salesforce.
I'm sending custom fields data to Salesforce through give_salesforce_donation_args
When a donation is made, the contact record is being created in Salesforce, however there is no opportunity being created.
This is also showing in the log.
Also I don't know if it's worth noting that in the backend of our GiveWP plug in, there are no Salesforce logs at all, it's not even an option on the drop down menu.
The code we are using is as follows:
`/**
@param array $args - associate array of data to be sent to Salesforce. example: ["Field_Name" => "Value"]
@param SalesforceOpportunityData $data - the original data object where you can access things like donationId. example: $data->donationId
@return array
*/
function addGiveSalesforceDonationArgs(
$args,
\GiveSalesforce\Salesforce\DataTransferObjects\SalesforceOpportunityData $data
) {
// get the formTitle
$formTitle = give_get_meta($data->donationId, '_give_payment_form_title', true);
// assign Salesforce field as formTitle
$args['Donation_Form_Name__c'] = $formTitle;
// relate GiveWP meta keys with Salesforce fields
$givewp_salesforce_fields = array(
"address_line_1" => "MailingStreet",
"towncounty" => "MailingCity",
"postcode" => "MailingPostcode",
"phone_number" => "HOC__Primary_Phoneno__c",
"email_sign_up" => "Website_Enews_Sign_up",
"text_sign_up" => "Fundraising_SMS_Opt_in__c"
);
foreach ($givewp_salesforce_fields as $gwp_key => $sf_field) {
// get the custom field from meta using the donationId from our $data DTO
$myGivewpCustomFieldForSalesforce = give_get_meta(
$data->donationId,
$gwp_key,
true
);
// assign the Salesforce custom field name to the GiveWP value
$args[$sf_field] = $myGivewpCustomFieldForSalesforce;
}
// return the modified array
return $args;
}
add_filter('give_salesforce_donation_args', 'addGiveSalesforceDonationArgs', 10, 2);`
Beta Was this translation helpful? Give feedback.
All reactions