First of all, thanks for developing and maintaining this great module.

The problem I've encountered is that the for a multipage webform with multiple conditionals is not firing.

Event
After a webform has been submitted

Condition: Webform has name
Parameters:
The form id of the submitted form: [form_id]
Webforms: Mid-program quiz

Action: Add user role
Parameters:
User: [user]
Roles: Mid-program quiz: Passed

It's fairly clear that it's a code issue because when I change Event to "After a webform has been saved as draft", the rule fires upon saving a draft, and the user role gets promoted.

Has anyone else had this problem? Any suggestions would be much appreciated!

Comments

Roensby’s picture

I have the same issue, except with no conditionals, only a multipage form.
If I remove the pagebreak component, the submission rule triggers.

edit: I think the problem concerns the setting in webforms "Automatically save as draft between pages"

If it is enabled, submissions have the is_new variable set to false, which in turn makes webform_submission_insert not call module_invoke_all('webform_submission_insert', $node, $submission); in webform.submissions.inc, thus the rule is never triggered.

If "Automatically save as draft between pages" is disabled, submissions trigger the "After a webform has been submitted" rule as they should.

grahamc’s picture

You should be able to get around the problem with drafts by reacting to both "After a webform has been submitted" _and_ "After a submission draft has been submitted" events.

... it's not at all obvious that one would need to use both events, though. Reacting when the form is finally submitted (whether via a draft submission or not) is likely the most common thing to want to do, so ought to be covered by a single Rules event.

guignonv’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1.1 KB

I made a patch that solved the problems I reported in issue #2262755 (https://www.drupal.org/node/2262755) which has been marked as duplicate of this one.

It's the first time I make a patch for a Drupal contrib' module using git so... be indulgent if I made some mistakes... and feel free to let me know what was wrong if any! ;-)
And of course, review the patch and report if it solved your problem.

guignonv’s picture

I found out that the full content of the submission was not passed to the rule handler (maybe because of a multiple-page webform). So I improved my previous fix with this one (that should replace it).

guignonv’s picture

Priority: Normal » Major
guignonv’s picture

hserus’s picture

Hi guignonv thanks for your patch, it's work great. But in my case it works only to the multipage webform not to single page webforms. Here I made small changes in your patch to make work to both single page and multipage webforms. I am not sure whether this is the proper way to apply patch and not yet created a new patch.

broon’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for this patch. It took me quite some time to actually find the source of my problem to be with webform rules.
Simply applied hserus' patch and it worked right away. Good job all of you!

hserus’s picture

albie001’s picture

Hi,

I am having the same problem with rules on a multi-page webform.

I have tried to apply patch 5 but keep getting the following error when doing so

patch: **** malformed patch at line 27: + $submission->data[$cid]['value'] = $value;

Any chance someone could provide me with the patched file?

albie001’s picture

UPDATE

I had been on a different machine and was trying to use cygwin to apply the patch.

Went back to using Netbeans and patch installed without issue.

Works like a charm.

Thanks

albie001’s picture

After applying patch 5 and after some further testing I am getting the following error message when submitting the form.

Notice: Undefined index: page_break in webform_rules_rules_invoke_event() (line 130 of .../sites/all/modules/webform_rules/webform_rules.module).

It doesn't appear to be causing any major issues other than the end users sees this message when they submit their form.

joelhsmith’s picture

Hey @albie001 I was getting the same error. Can you hook me up with that sucessfully patched file?

joelhsmith’s picture

Never mind. My issue was actually this: https://www.drupal.org/node/2487540#comment-10311045

_vid’s picture

@hserus
We were experiencing some issues with the patch syntax when trying to apply webform_rules-submission_rule_firing-1964590-5.patch

Specifically:

$ git apply -v --check webform_rules-submission_rule_firing-1964590-5.patch
fatal: corrupt patch at line 45

So I manually applied the changes from the patch and rolled a fresh one that is effectively the same but applies w/ no errors to the 7.x-1.6 release and the 7.x-1.x head (as of today: commit: 42a1801).

While I haven't tested the functionality of the patch itself, if it's the right solution then hopefully this will help folks leverage your solution.

silurius’s picture

Thank you, @_vid. #15 works well here so far. Let's RTBC it!

john_b’s picture

Status: Reviewed & tested by the community » Needs work

I am reluctantly setting this back to Needs Work. The patch does ensure that the Action 'create node' fires. However, on a mutli-page form the webform submitted data is not reliably available for using rules to do a Rules 'set data' action i.e. to populate a node field, froma form submission field. The only data reliably available is basic node data from the Webform.