I'm thinking this is done through PHP Execution after an event using the Replacement patterns below. Anybody has a take on it or a sample code?

Replacement patterns for The submitted webform data

TOKEN LABEL DESCRIPTION
[data:sid] Submission Id The unique identifier of the submission.
[data:data] Submitted data The submitted webform data.
[data:data-raw] Raw submitted data The unfiltered submitted webform data.
[data:{component}-title] Component title The title of the selected component, e.g. "email-title".
[data:{component}-value] Component value The value of the selected component, e.g. "email-value".
[data:{component}-value-html] Component value as html The value of the selected component rendered as html, e.g. "email-value-html".
[data:{component}-value-raw] Raw component value The title of the selected component, e.g. "email-title".
[data:{component}-display] Component display Title and value of the selected component, e.g. "email-display".
[data:{component}-display-html] Component display as html Title and value of the selected component rendered as html, e.g. "email-display-html".

Comments

emptyvoid’s picture

My recommendation using PHP in your action state of the rule.


  $variables = array();
  $variables[] = $data->fieldname['value'];

  drupal_go_to('http://www.example.com/target_page', array('query' => $variables)); 

http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_goto/7

** of course to figure out what the data is structured you'd need to first have the rule trigger a message that prints the $data object, like so:

<pre>
<?php
  print_r($data);
?>
</pre>
stborchert’s picture

Status: Active » Closed (works as designed)

Please reopen if any question is unanswered or you need more help.

bisonbleu’s picture

In #1, the last line of the first code block should read

drupal_goto('http://www.example.com/...

No underscore between 'go' and 'to'.

bisonbleu’s picture

This works great! I'm able to POST the values of a simple webform to a Moneris sandbox with the following.

drupal_goto('https://example.com/ABCD/index.php', array('query'=>array(
  'ps_store_id'=>'xxxxxx',
  'hpp_key'=>'yyyyyy',
  'charge_total'=>'50.00',
  'description1'=>'Donation',
  'quantity1'=>'1',
  'bill_first_name'=>'Bison',
  'bill_last_name'=>'Bleu'
)));

In the above, I've hardcoded data for a simple test. It works! Can someone suggest code for looping through $data? I'm not a programmer and I don't know where to start.

Here is a sample of what I get when I print_r($data);

Array
(
    [op] => insert
    [sid] => 1
    [components] => Array
        (
            [ps_store_id] => Array
                (
                    [value] => Array
                        (
                            [0] => xxxxxx
                        )

                    [component] => Array
                        (
                            [nid] => 174
                            [cid] => 1
                            [pid] => 0
                            [form_key] => ps_store_id
                            [name] => ps_store_id
                            [type] => hidden
                            [value] => xxxxxx
                            [extra] => Array
                                (
                                    [hidden_type] => value
                                    [conditional_operator] => =
                                    [private] => 0
                                    [conditional_component] => 
                                    [conditional_values] => 
                                )

                            [mandatory] => 0
                            [weight] => 0
                            [page_num] => 1
                        )

                )

            [hpp_key] => Array
                (
                    [value] => Array
                        (
                            [0] => yyyyyy
                        )

                    [component] => Array
                        (
                            [nid] => 174
                            [cid] => 2
                            [pid] => 0
                            [form_key] => hpp_key
                            [name] => hpp_key
                            [type] => hidden
                            [value] => yyyyyy
                            [extra] => Array
                                (
                                    [hidden_type] => value
                                    [conditional_operator] => =
                                    [private] => 0
                                    [conditional_component] => 
                                    [conditional_values] => 
                                )

                            [mandatory] => 0
                            [weight] => 1
                            [page_num] => 1
                        )

                )

            [charge_total] => Array
                (
                    [value] => Array
                        (
                            [0] => 50.00
                        )

                    [component] => Array
                        (
                            [nid] => 174
                            [cid] => 3
                            [pid] => 0
                            [form_key] => charge_total
                            [name] => charge_total
                            [type] => hidden
                            [value] => 50.00
                            [extra] => Array
                                (
                                    [hidden_type] => value
                                    [conditional_operator] => =
                                    [private] => 0
                                    [conditional_component] => 
                                    [conditional_values] => 
                                )

                            [mandatory] => 0
                            [weight] => 2
                            [page_num] => 1
                        )

                )
                
                etc.
bisonbleu’s picture

I'm making progress. The following code works; it produces the same output as in #4. Feel free to comment and/or improve it. In fact, that would be appreciated.

  $variables = array();
  foreach($data['components'] as $component => $field_key) {
    $variables[$component] = $field_key['value'][0];
  }
  drupal_goto('https://example.com/ABCD/index.php', array('query'=>$variables));
j4’s picture

Bisonbleu,

I have been going crazy for the past 10 days trying to get a rule to work on creation of a node. The rule is a execute php action that needs to collect user profile details as well as field values from the node created and post this information to an external site. When i ran the code with static valiues, all was fine and the posted information was getting received by the external site. BUt try as i might i am not able to read the values of the address fields in my content type using php. Can you help me? Am really desperate..:(

Thanks
Jaya

bisonbleu’s picture

Hey Jaya,

I know what it's like to go crazy... :)

I'm no expert. But here's what I've learned from watching Nodeone's series on Rules - HIGHLY RECOMMENDED! (see references below).

When a rule is triggered, not all required objects are available. For example, when a Story node is created by a user, his profile is not available. If he's got a signature in his profile you can't access it when the Story node is created.

So what do you do? This is where Rule Sets come in and save the day. By using a Rule set, you can load the objects you need (such as a user profile). Once that object is loaded, you then have access to all its data.

Have a look at the following screencasts. They are for Drupal 6. But I'm pretty sure they apply to Drupal 7.
- episode #6 Introduction to the Rule Set concept: http://vimeo.com/17754350
- episode #7 Conditions on loaded objects: http://vimeo.com/18005306

And there's a new series for Rules under Drupal 7 here: http://nodeone.se/sv/node/32

Hope this helps!

j4’s picture

Hi,

Thank you for replying! I got it done by using wrappers and entity metadata finally thanks to some great help from the drupal IRC. You are right, about not all the information being present. Am happy to have learnt something,

Thanks again
Jaya