Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It would be useful to have the ability to alter field data before it is submitted to Salesforce. Salesforce Suite has such a hook: hook_salesforce_push_params_alter. It appears that that hook is not invoked in Salesforce Webforms. I propose adding a similar hook to Salesforce Webforms and I've created a patch to add it.
Comment | File | Size | Author |
---|---|---|---|
#4 | interdiff-2504921-1-4.txt | 2.33 KB | dbcollies |
#4 | salesforce_webforms-2504921-4.patch | 1.96 KB | dbcollies |
#1 | add_hook_to_alter_field_data-2504921.patch | 1.48 KB | Peter Caritas |
Comments
Comment #1
Peter Caritas CreditAttribution: Peter Caritas commentedComment #2
dbcollies CreditAttribution: dbcollies commentedYou are correct that this functionality isn't currently supported, and it makes sense to do so. Thanks very much for submitting a patch. I haven't had time to review/test your code yet, but I'll get to it when I can, unless somebody else wants to take a shot at it first.
I DO think that I'd prefer a different hook name, though.
hook_salesforce_webforms_push_params_alter
may be consistent with the hook in Salesforce Suite, but I think thathook_salesforce_webforms_save_submission_alter
would be more consistent with the other hooks in this module, as well as "common convention." There are also some Drupal coding standards violations in your patch, but I can clean those up when I'm ready to commit it.Comment #3
dbcollies CreditAttribution: dbcollies commentedA quick review shows that the supplied patch needs a little work. The call
drupal_alter('salesforce_webforms_push_params', $fields, $map, $node, $sub)
insalesforce_webforms.module
uses a deprecated form of thedrupal_alter
function. New code using this function should not use more than 4 parameters.I would suggest combining the $map, $node, and $sub parameters into a new associative array, and pass THAT as the 3rd parameter, and eliminate the 4th and 5th parameters. Of course, the corresponding docblock would also have to be updated to reflect this.
Comment #4
dbcollies CreditAttribution: dbcollies commentedThis patch should implement the feature you've requested. I'll leave it in "Needs Review" state for a few days. If nobody finds any issues, I'll publish it in a few days as a part of the 1.0 release.
Comment #6
dbcollies CreditAttribution: dbcollies commentedSince there have been no complaints about this patch, I've committed it to the DEV branch, and it will be included in the next release.
Comment #7
Peter Caritas CreditAttribution: Peter Caritas commentedHello, thanks for the quick action on this! That all sounds good to me. I haven't had a chance to try out your changes but it all looks pretty straightforward and make sense to me. Thanks again!
Comment #9
Peter Caritas CreditAttribution: Peter Caritas commentedHello,
I'm reopening this as it appears that hook_salesforce_webforms_save_submission is already in use in the module. Also the api doc file still refers to hook_salesforce_webforms_push_params_alter. I guess a new/different name hook name is needed.
Comment #11
dbcollies CreditAttribution: dbcollies commented@Peter Caritas you are correct. The call to
drupal_alter()
had the wrong hook name. It has now been fixed.