0

Here is the situation and what I want to do:

  • Users have a "days left" field of type integer.
  • A user will set a date range while creating a "time off" content type.
  • When he hits the save button, a rule will intercept, subtract the date range from his "days left" field and save the result as the new "days left" value.

here is what I have done:

  • user clicks save button rule intercepts
  • action - gets the duration and divides it by 86400 (to convert it to days from seconds)
  • action - converts the result to integer
  • action - subtracts the converted value from content authors "days left" field.

At this point I want to assign the result of the subtraction to the author's "days left" field. The node:author:field-days-left variable is available and I select it. But the result of the subtraction is not.

I also tried to convert the result of the subtraction to integer and then assign it, but it did not work too.

Any ideas why?

0

I could not figure out why the result variable was not available; my solution was to change the order of the actions to:

After the user clicks save button, rule intercepts:

  • get the value of author's "days left" field and multiply with 86400 (convert days to seconds)
  • get the duration of content and subtract it from the previous value
  • divide the result by 86400 (convert it back to days from seconds)
  • convert the result to integer
  • subtract one from this result (this turned out to be necessary, perhaps because of the rounding off during the type conversion)
  • assign the result to content author's "days left" field.

I do not like having to make two type conversions but this is a working solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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