Hi,
Lately I created some rules to set a start and end date on the saved node.
The start/end date fields are of type date with a popup selector.
The choosen event was fired, the rules debug text said: "100.252 ms Evaluating the action data_set. [edit]"
No error! But the date fields stayed empty!?!
In the rules I check for the date fields:
{ "entity_has_field" : { "entity" : [ "node" ], "field" : "field_guide_from" } },
{ "entity_has_field" : { "entity" : [ "node" ], "field" : "field_guide_to" } },
and this is how I want to set the values:
{ "data_set" : { "data" : [ "node:field-guide-from" ], "value" : "now" } },
{ "data_set" : { "data" : [ "node:field-guide-to" ], "value" : "now +1 year" } },
Since I updated the Date module from 2.3 to 2.5, I can't directly access the value anymore ([ "node:field-guide-to:value" ])
Environment:
Rules version 7.x-2.1
Date version 7.x-2.5
Entity API version 7.x-1.0-rc1
Any ideas, help!?!
Thx, ifux
Comments
Comment #1
ifux commentedAdditional information:
There's a notice in the reports that says: The variable or parameter 0 is empty.
But first time it has to be empty!?
Comment #2
ifux commentedhi there,
found some time to go through my rules again and trying to debug.
I trigger my rules on my own (created) event, so I tried it once with the node-update event.
Then the date setting worked! So I thought perhaps I set the date "to late" and have to save the entity again, so I changed back to my own event and added a "save entity" action... no date set :-(
But there is a fact that is somehow suspicious:
Looks like the entity is being saved AND it fires a rule that reacts on date value change?!?!?!
Any ideas/advices!?! Would be great!!!
thx, ifux
Comment #3
berdirCannot reproduce this with the following, simple rule. I assume this is a combination of multiple rules or custom code that change stuff that they shouldn't.
Comment #4
wipeout_dude commentedI am having the same issue..
I have an "attendance" field to store a start date/time and end date/time record..
To test I created a run "when item is viewed" - "content is of type " - "set data value - attendance date 'value' = now"..
It didn't appear to do anything, the rule was running because it was displaying a "system message" but the date field was not updating..
I thought it maybe because the field required an end date so I removed the requirement but it still didn't save the field..
Not sure how else to test it to get closer to why its not working..
Comment #5
ifux commentedYES! It finally works!
I don't really know why?!
I change the "place" where my rules gets invoked. First I invoked it in the first submit function of the button and know I invoke it in the last submit function of the button.
Can anybody explain to me why and what that changes?!? I thought 'cause the form_state variable is pasted by ref, it should take all the changes on from one submit function to the other.
By the way, the date fields should not be touched in any other submit function I have!
Comment #6
fnapo commentedSame stuff, "Set a data value" from a Rule Parameter (date start and stop) doesn't actually change the node field date (start - end)
Date API 7.x-2.5
Rules 7.x-2.1
Comment #7
ptmkenny commentedJust a heads up-- I recently traced an issue with "set a value" to entity rc3 and entity translation alpha2.
Comment #8
fnapo commentedReverting to Entity rc1 worked for me too
Comment #9
fnapo commentedDebugging Rules Component, I actually found this error for updating a date field:
what do you think is the core problem?
thanks
Comment #10
eliaspallanzani commentedwith Rules version 7.x-2.2
Date version 7.x-2.6
trying to set a date field with a text
php
$field = field_get_items('entity', $entity, 'field_datina');
$field1= date('Y-m-d', strtotime($field));
$value = $field1[0]['value'];
return $value;
don't work
and dont' work with integer, with text...
Comment #11
tobiasbI updating a date field (unix timestamp) with the http://drupal.org/project/interval module. Which works fine.
Comment #12
ptmkenny commented@tobiasb This is a bug report about an incompatibility with the Rules module. Since both Date and Rules are in widespread use, this is an issue for many people. Please don't change the category without good reason.
Comment #13
koppie commentedApparently this will only work if the field already has a default value. See #1431952: Date field will only set in Rules if it already has a value.
I'm marking this issue as a duplicate, even though the other issue is for the Date module. Feel free to reopen this issue (and close that one) if you can provide a solution that is Rules-centric.
Comment #13.0
koppie commentedTypo ;-)
Comment #14
dan.mantyla commentedsee this: https://www.drupal.org/node/1231418