Unable to create node in custom Rules action

by asntbladewriter   Last Updated December 04, 2017 22:07 PM

I am currently working on a custom action in rules to create and prefill several nodes when a trigger node is created, but I've run into some trouble. (I am doing this through custom action because the number of 'set data value' line items I need does not allow me to weight the rules properly. When I create the trigger node, the rule action node is not created, and there are no errors to speak of. I thought there may have been trouble with the condition, but when I purposefully left errors in the code, the errors would appear when the trigger node was created, so I know it is being triggered correctly. The action node is just...not created and I'm not sure why. Any advice would be greatly appreciated.

P.S. I checked the database directly, and there are no signs of the rule created node their either.

* Implements hook_rules_action_info()
* Declares Rules action metadata
function bladewriter_rules_action_info() {
    $actions = array(
        'bladewriter_action_create_bes4u' => array(
            'label' => t('Create Order Record Entries for S4 BE Unit'),
            'group' => t('Order Record Units'),
            'parameter' => array(
                'new_node' => array(
                    'type' => 'node', 
                    'label' => t('Current Node')),

return $actions;

*bladewriter_action_create_bes4u() action

function bladewriter_action_create_bes4u($new_node) {

    global $user;

$values = array(
  'type' => 'order_record',
  'uid' => $user->uid,
  'status' => 1,
  'comment' => 0,
  'promote' => 0,

$entity = entity_create('node', $values);

$ewrapper = entity_metadata_wrapper('node', $entity);

$entity->field_order_date[LANGUAGE_NONE][0] = array(

  'value' => $new_node->field_order_date[LANGUAGE_NONE] [0] ['value'],
  'timezone' => $new_node->field_order_date[LANGUAGE_NONE] [0] ['timezone'],
  'timezone_db' => $new_node->field_order_date[LANGUAGE_NONE] [0] ['timezone_db'],

$ewrapper->field_customer = $new_node->field_customer[LANGUAGE_NONE] [0] ['value'];

$ewrapper->field_purchase_order_ = $new_node->field_purchase_order_[LANGUAGE_NONE] [0] ['value'];

$ewrapper->field_new_order = 0;

$ewrapper->field_use_custom_pricing = 0;

$ref_nid = 10;




Related Questions

Date field comparison in Rules

Updated March 23, 2017 10:07 AM

Returning a variable from a rules action

Updated September 02, 2016 08:04 AM