Last updated 18 April 2012. Created on 29 May 2011.
Edited by mitchell, itserich. 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 forums, or join #drupal-support in IRC.


tHe_WooKiE’s picture

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!!