Thanks to #1153766: provide a property setter callback the Date field can now be set in Rules. However, it seems to only work if the date field already has a value. If the value is blank, it won't get set.
I'm using Drupal 7.12, Rules 7.x-2.x branch, and Date 7.x-2.x branch.
This is the error log that Rules is spitting out:
# 1.02 ms Evaluating the action data_set. [edit]
# 3.931 ms Unable to modify data "eval:field-open-date:value": Unable to set the data property value as the parent data structure is not set.
# 7.665 ms Unable to evaluate action data_set. [edit]
# 8.716 ms Evaluating the action data_set. [edit]
# 10.118 ms Unable to modify data "eval:field-open-date:value2": Unable to set the data property value2 as the parent data structure is not set.
# 11.489 ms Unable to evaluate action data_set. [edit]
Comment | File | Size | Author |
---|---|---|---|
#43 | date-1431952-43.patch | 1.24 KB | lzimmerman |
#42 | date-1431952-42.patch | 1.2 KB | gcb |
#32 | date-1431952-32.patch | 1.2 KB | Cadila |
Comments
Comment #1
arlinsandbulte CreditAttribution: arlinsandbulte commentedLet's let fago have a look at this first.
Then it can be moved back to the date module issue queue if needed.
Comment #2
milos.kroulik CreditAttribution: milos.kroulik commentedI also seem to have this issue, when trying to load vocabulary and set term into it. See my exported rule: http://drupalbin.com/21099
Comment #3
fagoI think that should be fixed with the recent 2.1 release - please try this one.
Comment #4
andrea.vivaldi CreditAttribution: andrea.vivaldi commentedTried with 2.1 release and this error still remains (i've tried with a Data field)
Comment #5
c.breschkow CreditAttribution: c.breschkow commentedWith the release 7.x-2.2 everything works perfect. If I upgrade to 7.x-2.3 I must enter the date field with a value. But the rule can't find this value.
Comment #6
webfeathers CreditAttribution: webfeathers commentedI am getting the same behavior.
Drupal 7.12
Entity 7.x-1.0-rc1 (with entity_i18n_string patch from http://drupal.org/node/1513406#comment-5824286)
Rules 7.x-2.1
Date 7.x-2.3
Rules debugger output (subset)
----------------------
0 ms Rule Set Last Published Date fires.
2.425 ms Evaluating the action data_set. [edit]
3.336 ms Unable to modify data "node:field-last-published-date:value": Unable to set the data property value as the parent data structure is not set.
7.329 ms Unable to evaluate action data_set. [edit]
7.377 ms Rule Set Last Published Date has fired.
-------------------------------
Rule content (Pretty simple) is:
{ "rules_set_first_published_date" : {
"LABEL" : "Set First Published Date",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "workbench_moderation", "rules" ],
"ON" : [ "workbench_moderation_after_moderation_transition" ],
"IF" : [
{ "AND" : [
{ "contents_current_state" : { "node" : [ "node" ], "moderation_state" : "published" } },
{ "entity_has_field" : { "entity" : [ "node" ], "field" : "field_first_published_date" } },
{ "data_is_empty" : { "data" : [ "node:field-first-published-date:value" ] } }
]
}
],
"DO" : [
{ "data_set" : {
"data" : [ "node:field-first-published-date:value" ],
"value" : [ "site:current-date" ]
}
}
]
}
}
Comment #7
andypostThis works for date 2.2 but broken for date 2.3, probably caused by #1153766: provide a property setter callback
Comment #8
mitchell CreditAttribution: mitchell commentedSeems like something changed between Date 2.2 and 2.3. Does this bug still exist in later releases?
Comment #9
KarenS CreditAttribution: KarenS commentedWe're up to Date 2.5 and there have been lots of changes. If there is still a problem in 2.5 someone will have to reopen with steps to reproduce.
Comment #10
davidwhthomas CreditAttribution: davidwhthomas commentedJust a note on this one, I was getting the same error with Date 7.x-2.3. ( Unable to set the data property value as the parent data structure is not set. )
However, after upgrading to the latest 7.x-2.5, the problem was solved!
Thanks KarenS!
DT
Comment #11
jamescl CreditAttribution: jamescl commentedI can reproduce on clean install using dev releases.
With single date (i.e. no end date) this works fine, however when 'collect and end date' is selected in manage fields this will not work if you are setting a start or end date when both do not have a value. When you have a start date already in the field you can overwrite it, or set an end date with no trouble.
Rules debug shows:
- (For start dates) Unable to modify data "node:field-name:value": Unable to set the data property value as the parent data structure is not set.
- (For end dates) Unable to modify data "node:field-name:value2": Unable to set the data property value as the parent data structure is not set.
Requiring (or not) an end date seems to have no impact.
Comment #12
wipeout_dude CreditAttribution: wipeout_dude commentedSame here.. If Date is empty rules won't set it.. All mine have start and end so haven't tested a single "value" date..
If date is already populated then both "value" and "value2" can be changed by a rule..
Date - 7.x-2.5
Rules - 7.x-2.1
Comment #13
wipeout_dude CreditAttribution: wipeout_dude commentedHi All,
Desperately need the ability to set and update date fields (start and end dates) from rules.. I haven't been able to find a suitable way to do what I need to any other way..
I don't mind contributing to someone's time to get it resolved and committed to whichever module is responsible..
Comment #14
jamescl CreditAttribution: jamescl commentedHave discovered it will set both values if you set it for the whole field (i.e. don't drill to value, value 2 level.)
Therefore you can set both values with one action without a value being set (in my case from another date field), and then set a single value with a second action to whatever.
Not sure if this will work if you don't have another date field in the content type, so leaving open - but at least there's a workaround for the moment.
Comment #15
wipeout_dude CreditAttribution: wipeout_dude commented@jamescl - Thanks for you reply..
Just had a crack at it and it appears that you can't set it to a relative value like "now" and the option some something like site:current-date isn't available.. oing to have to give it some thought in the morning as to where I can get a usable date from to populate the field before updating "value" and "value2" to the required values..
Really hope it works because this is a big roadblock for me at the moment..
Comment #16
jamescl CreditAttribution: jamescl commentedThe only way I can think to do it would be to create a new field that is only visible to admins with a default value and use that for rule. Isn't ideal to have a completely useless set of dates for every node, but it would get the job done until a fix for this can happen.
Comment #17
wipeout_dude CreditAttribution: wipeout_dude commented@jamescl - I have tried this but it doesn't seem to work for me..
Only other option I would have is to create two separate fields for start date and end date but that would break all calendar functionality that I was planning with the date information which is not something I would really like to sacrifice..
Comment #18
Chi CreditAttribution: Chi commentedRelative issue: #1696594: Setting data to double field through rules
Comment #19
maxplus CreditAttribution: maxplus commentedHi,
I have the same problem using:
Date - 7.x-2.6
Rules - 7.x-2.2
I have not found a workaround for this, even when trying to use a single date without a end date.
I hope there will come a solution in het next release of the Date or Rules module...
Comment #20
wipeout_dude CreditAttribution: wipeout_dude commentedOnly work around that works is as per #16 which is copying a date field from somewhere else in your rule and then change it to what you want it to be.. A little messy but at least you can create your solution.. As you say, hopefully this gets resolved because it will help simplify my rules..
Comment #21
dwightlathan77 CreditAttribution: dwightlathan77 commentedUsing Date - 7.x-2.6 and Rules - 7.x-2.2 I can't use the date getter or setter on datetime fields with start and end dates, regardless of whether the end date is needed or not on objects being created. I can't reference other date objects either.
A workaround is to use php code to programmatically create the node and set initial date values. This can be done through a custom module or through the Rules UI as an action triggering the php.
I really hope someone is still working on getting this functionality working. This is a reason why a configurator may need to use php, but shouldn't be considered an excuse.
Comment #22
koppie CreditAttribution: koppie commentedMarking #1611666: Action "Set a data value" is not working for date field as a duplicate of this issue - but that one might be worth keeping an eye on, because it's in the Rules module. I'm also upgrading the priority of this issue to "major" because (a) it actually keeps things from working and (b) it's been unsolved for a year and a half.
Does anyone have any ideas for solving this? I don't even know where to start.
Comment #23
Cadila CreditAttribution: Cadila commentedI faced this problem today. It's really annoying. The problem is in date module that doesn't provide auto creation callback for struct dates (with begin date and end date fields). This should solve the problem.
Comment #24
ivanhelguera CreditAttribution: ivanhelguera commentedwow, #23 worked for me. I'm all in tears! Thank you!
Comment #25
vijaycs85Comment #27
Cadila CreditAttribution: Cadila commentedre-uploading patch cause the old one have failed the tests
Comment #28
Cadila CreditAttribution: Cadila commentedSorry, wrong paths again. Fixed.
Comment #29
andypostComment #30
andypostAwesome! Let's get this in
Comment #31
maximpodorov CreditAttribution: maximpodorov commentedFunction arguments are not described in the docblock.
Comment #32
Cadila CreditAttribution: Cadila commentedFixed phpdoc according to notice in comment #31
Comment #33
Cadila CreditAttribution: Cadila commentedComment #34
Cadila CreditAttribution: Cadila commentedComment #35
maximpodorov CreditAttribution: maximpodorov commentedComment #36
Tulika CreditAttribution: Tulika commentednot able to solve this issue
Comment #37
podarokComment #38
podarok32: date-1431952-32.patch queued for re-testing.
Comment #39
maximpodorov CreditAttribution: maximpodorov commentedThe patch is used on the production sites and solves the problem.
Comment #40
vijaycs85Thanks @Cadila. committed 7faeea3 and pushed to 7.x-2.x
Comment #42
gcbRe-rolled against 7.x-2.6. Thanks for this, fixed a big issue with SF module date syncing!
Comment #43
lzimmerman CreditAttribution: lzimmerman commentedRe-rolled against 7.x-2.7. Worked to fix rules handling of date fields. Thanks!
Comment #44
maximpodorov CreditAttribution: maximpodorov commentedMaybe it's better to make a new release of Date module instead of re-rolling patches.
Comment #45
AaronBaumanWhy are people still posting patches?
Was this fixed or not?
Comment #46
kopeboy CreditAttribution: kopeboy commentedI am using Date 7.x-2.8 and Rules 7.x-2.7, and still this doesn't work, neither if I have a default value for the date field (normal date field, no repeat, no interval) nor if I have a default value.
My rule fires After saving content, set the data value (all fields are loaded), and save the entity.
When I try to create that entity as a User (the date field in question is not visible to the user in the form, hided by Display Suite, no custom field permissions) I get this error "The value input for field 'My date field' is invalid." and I can't create the node.
I am using "Cache dates", maybe that is the problem?
EDIT: Ok, nevermind, even if I had no errors in the rule, I had to load the specific date field with 'Entity has field', while other fields I am saving in the same rule were working correctly just with 'Entity is of bundle' condition.
Comment #47
kopeboy CreditAttribution: kopeboy commented