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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Peter Caritas’s picture

dbcollies’s picture

You 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 that hook_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.

dbcollies’s picture

Status: Active » Needs work

A quick review shows that the supplied patch needs a little work. The call drupal_alter('salesforce_webforms_push_params', $fields, $map, $node, $sub) in salesforce_webforms.module uses a deprecated form of the drupal_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.

dbcollies’s picture

Status: Needs work » Needs review
FileSize
1.96 KB
2.33 KB

This 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.

dbcollies’s picture

Status: Needs review » Fixed

Since 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.

Peter Caritas’s picture

Hello, 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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Peter Caritas’s picture

Status: Closed (fixed) » Needs work

Hello,
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.

  • dbcollies committed 0e6e2fa on 7.x-1.x
    Issue #2504921 by peter-caritas, dbcollies: Fixed wrong hook name.
    
dbcollies’s picture

Status: Needs work » Fixed

@Peter Caritas you are correct. The call to drupal_alter() had the wrong hook name. It has now been fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.