I need a bit of help with Rules. I'm trying to create a rule that if a check box is checked on one entity, change the value of another checkbox on another entity. I have the conditions "Entity has field - Checkbox A" + "Data Comparison Checkbox A, value = Checked". But for the Action, I don't know how to set the value of Checkbox B on the other entity.

More detail: it's for a hotel booking site. I have an entity for the booking and an entity for the room itself. I want it so that when the "Checked-out" box is selected in the booking entity, the "Needs Cleaning" box in the room entity is checked. The two entities are linked by the room_ID number.

  • Update: got it to work in rules. Checkbox A was done in the rule as mentioned above. Checkbox B I did the same way but in a component. I added it to the rule as the action. I ran into a problem with Rules not being able to tell that checkbox A was checked but this link solved that problem drupal.stackexchange.com/questions/28750/…
    – Ash
    Aug 23, 2013 at 18:45

1 Answer 1


You may need to write a quick custom action for this given your use case but its fairly easy to do. First create a custom module and add this hook to declare that you are creating a new action to be taken when 'someone checks out'.

 * Implements hook_action_info().

function YOURMODULE_action_info() {
  return array(
    'YOURMODULE_room_checkout_action' => array(
      'label' => t('Action to take after someone checks out'),
      'type' => 'node',
      'configurable' => FALSE,
      'triggers' => array('any'),

Presumably, you want to attach this action to the trigger you already have, perhaps 'when booking content type is updated'.

Next, all you need to do is write your payload function that gets triggered for the action. The name for this is the same as what we defined in the array above. After that, you just need to set the two values which is a bit more involved but the pseudo code here should get your started.

 * Action function for 'check out of room' action.
 * @see action_example_action_info()
function YOURMODULE_room_checkout_action(&$entity, $context = array()) {

  // find entity id for your room entity and load entity as $room
  // set $room->needs_cleaning field to 1 (or same value as $booking->checked_out
  // note that the $entity passed here is the one from your trigger (ex. the booking node)

  • Thank you for your suggestion. Unfortunately, I'm not that well versed in PHP. Is there no way to it in Rules? I have the condition set up: Once a booking is saved - entity has field (checked out) + data comparison (is "checked out" = 1). I'm stuck on the action to set "Needs Cleaning" on the room entity type.
    – Ash
    Aug 22, 2013 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.