Closed (fixed)
Project:
Rules
Version:
7.x-2.x-dev
Component:
Rules Core
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
7 Mar 2011 at 02:55 UTC
Updated:
8 Feb 2016 at 08:36 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
shadow_jh commentedI should probably say what Im trying to achieve. Basically, I want my select box field on my node which looks like this:
to become the scheduled components data selector field. However, that field does not show up as an option currently.
Comment #2
fagoOh, you would need a duration field then. However one can use an integer in 'seconds' as duration, so if you create a integer list you should be able to use it as duration.
Still, we are missing a way to do "Date + duration". I'd suggest we add a "Calculate data value" action which is able to some basic math with variables based on the date type, e.g. for dates only support +-, while for numbers we could support +-*/.
Comment #3
shadow_jh commentedAt the very least I should be able to use custom php to calculate the correct time of scheduling. That however does not seem to work either.
Comment #4
thechanceg commentedSubscribe
Comment #5
fago>At the very least I should be able to use custom php to calculate the correct time of scheduling. That however does not seem to work either.
You should be able to do that by using data selection & select just anything, then apply the PHP data processor to return whatever you want.
Anyway, at least we might want to enable tokens as that might already suffice for your use-case? For PHP evaluation the date text input field is too small I think.
Patch attached.
@calculate: I've opened #1151738: Support calculations for that.
Comment #6
fagoAs we have the calculation action now, using that is the preferred way I guess.
Comment #8
Gray Fox commentedI'm re-opening this as support request, since I'm still unable to create a scheduled rule to be executed X (integer type) days after an event date (date type). I also can't seem to use an integer list as duration (from #2).
EDIT: I ended up crafting my own module for that.
Turns out extending rules is pretty simple. Still, I think core should have some functionality like this, or I missed something obvious. Waiting for maintainer to give his opinion.
Comment #9
fagoYou can just specify now + a fitting date offset (number of days) as scheduled date.
Comment #11
jraviotta commentedThis is 90% of the solution that I need. The only problem is that I can't get a variable offset into the calculation. Perhaps I am overlooking a simple fix. Here is the use case:
I have a list of template tasks. Each task has a due date defined as an offset value (integer # of days) + "now".
On group creation, each task template node is copied to a new new content type one field at a time, and assigns the new group og_group_ref through rules. l can get everything to work fine except for the calculation of the specific due date for the copied group-specific tasks since there is no data selector for duration in the date calculation. This function requires a known value. Since the offset value for different tasks is variable, I can't use them in the calculation.
I'm working on creating a custom action that does the math, but i think this functionality could be useful to other rules users.
I have also had a hard time understanding what the php evaluation fields are capable of doing. For example, I finally found this thread that told me that custom PHP could not set variable values, but I tried that approach for too long before searching to see if It was possible. I would love a handbook page about how they should/should not be used.
If there is a way to use a token value in the duration field, or some php evaluation, perhaps someone could help me understand that strategy.
thanks in advance for your help!
Comment #12
danon1981 commentedI have ran into a similar situation where I need to be able to schedule based on a dynamic value so I have put in a feature request for this feature Schedule offset based on entity value
Comment #13
jimafisk commentedI wrote a custom action that may be similar to what jraviotta was looking for: https://www.drupal.org/sandbox/jimafisk/2663768
Basically you can take an existing date value, then pass a strtotime() parameter such as "+1 day" or "next Thursday" and it will create a variable with the combination that you could then use to schedule a component or do whatever you want.