Is there support for a wildcard in a submission URL within a Rule? And how do you grab the value of a field from a specific submission?
I'm trying to create a relatively simple workflow process:
Anonymous User submits a webform
-> Submission emailed to form recipient with submission-url/approve or submission-url/deny links included
--> Form recipient can click on either link to "approve" or "deny"
---> When either link is clicked by an Authenticated User with specific role, an automated email response is sent to the originator of the submission with a message like: "Your request has been approved." or "Your request has been denied."
This is how far I have gotten:
1. I can append "approve" and "deny" to the end of the submission URL easily enough and insert it into the email the form recipient receives using the email templates built-in to Webform. For example: http://mysite.com/node/[nid]/submission/[sid]/approve.
2. I have also created a working rule:
Event:
Drupal is initializing
Conditions:
Data comparison (compare [site:current-page:url] with node/[nid]/submission/[sid]/approve )
AND
User has role ([site:current-user] has [approval-role])
Action:
Send mail: TO [my email]
This works if the rule has the specific [sid] and a specific email in the TO field.
However, in the rule above, I need to change the [sid] in the URL to a wildcard (* or % or something) and the [my email] to the value in that specific form submission's email field. Any ideas how to accomplish this?
Comments
Comment #2
jacquelynfisher commentedComment #3
jacquelynfisher commentedComment #4
jacquelynfisher commentedOkay, I figured out half of my problem, and I want to share just in case someone else is trying to do something similar.
I modified the rule:
Event:
Drupal is initializing
Conditions:
Text comparison (data selector: [site:current-page:url] , value: node/[nid]/submission/\d+/approve , Comparison operator: regular expression )
AND
User has role ([site:current-user] has [approval-role])
Action:
Send mail: TO [my email]
I switched from data comparison to text comparison to get access to the regular expression and then used \d+ as a wildcard for [sid] which is comprised of numbers.
Now I need to figure out how to send the email message to the value of the submission's email field...
Comment #5
jacquelynfisher commentedI created another Action that fetches submission values, but how do you fetch values from submissions when the [sid] changes depending upon the URL clicked?
I tried a ton of different PHP codes but here is my latest attempt:
Action #1:
Fetch webform submissions
Parameter: Node ID: [my-nid]
Provides variables: Fetched submissions (submissions)
where Submission ID is taken from the current path's URL using PHP:
Action #2:
Send mail
Parameter: To:
<?php print $data['components']['test_email']['value'][0]; ?>I still get the error message: "Unable to send e-mail." I cannot seem to get the value of the test_email field, even when I replace the PHP with a SID.
Comment #6
jacquelynfisher commentedComment #7
jacquelynfisher commented