Last updated April 18, 2012. Created by itserich on May 29, 2011.
Edited by mitchell. Log in to edit this page.

We have a phone book and need a way to record when a fax number dialed is incorrect to remove it when there are too many incompleted attempts.

Created a cck field errors_fax_text

Type - text field.

Advanced PHP Code in the action:

return array(
  0 => array('value' => $node->field_errors_fax_text[0]['value']++),
);

I first tried using a field type integer, replacing the value in the php action with integer, but it did not work, and do not now why it did not work.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

1. Create a CCK field type integer (widget type: text field) and set the default value to 0

2. Create a triggered rule, giving it an appropriate label and choosing the event you want it to fire on.

3. Add an action "Load content by id". Fill in the Content ID field with the node id of the node that has the CCK field that you want to increment, and give it a label such as the default "node_loaded".

4. Add an action "Populate a field". Choose the content label given in the previous step, in this case "node_loaded". Leave the field under the field name at 0. Click the "Advanced: Specify the fields value with PHP code" fieldset and in the "Code:" textfield add

return array(
  0 => array('value' => $node_loaded->field_name[0]['value'] +1),
);

The $node_loaded corresponds to the label in step 3, and the field_name corresponds to the CCK field name in step 1.

And Robert's your mother's brother!!