# Schedule a log based on a quantity value

**URL:** <https://farmos.discourse.group/t/schedule-a-log-based-on-a-quantity-value/115>\
**Category:** Using farmOS\
**Created:** [October 26, 2019, 6:36pm UTC](https://farmos.discourse.group/t/schedule-a-log-based-on-a-quantity-value/115 "2019-10-26T18:36:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul121](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@paul121](https://farmos.discourse.group/u/paul121)\
**Post date:** [October 26, 2019, 6:36pm UTC](https://farmos.discourse.group/t/schedule-a-log-based-on-a-quantity-value/115/1 "2019-10-26T18:36:04Z")

</div>

I was playing with Equipment assets today. Specifically in the use case of a Tractor. It would cool if you could automatically “schedule” a maintenance task in the future, once a tractor has reached X amount of hours.

Here’s the idea: you might not be able to accurately schedule the oil change task just guessing the date. But lets say you weekly or monthly record the hours/mileage/etc on the tractor - once you get close to this “target” value for the maintenance task, a log could automatically be created and assigned to a user.

I don’t imagine this is possible right now, but is interesting to think about. I think the general use case comes down to linking “log creation” to a “log quantity” value. Another use case might be: once 500 pounds of X are harvested, create a log to do XYZ…

Thinking even further, “once the hay field is cut” (an activity/harvest log marked as “done”), create a task to “bale the field” two weeks later. (and create the task sooner if its forecast to rain…)

---

<div class="post-metadata">

**Author:** ![paul121](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@paul121](https://farmos.discourse.group/u/paul121)\
**Post date:** [October 26, 2019, 6:38pm UTC](https://farmos.discourse.group/t/schedule-a-log-based-on-a-quantity-value/115/2 "2019-10-26T18:38:32Z")

</div>

I’m wondering if we could create some kind a of system to add this capability. Using hooks after logs are updated/created, fire off checks to see if a “rule” has been created for that circumstance

---

<div class="post-metadata">

**Author:** ![Skipper](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@Skipper](https://farmos.discourse.group/u/Skipper)\
**Post date:** [October 27, 2019, 5:57am UTC](https://farmos.discourse.group/t/schedule-a-log-based-on-a-quantity-value/115/3 "2019-10-27T05:57:23Z")

</div>

Could also make a little checker bot in python (other programming languages are available) that reads through the logs and checks

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [October 28, 2019, 5:01pm UTC](https://farmos.discourse.group/t/schedule-a-log-based-on-a-quantity-value/115/4 "2019-10-28T17:01:11Z")

</div>

> Using hooks after logs are updated/created, fire off checks to see if a “rule” has been created for that circumstance

This would be pretty simple in a custom module. Not much code needed. Making it more flexible would be the challenging part… but…

There’s a module for that! And it’s called “Rules”! 🙂

> **[Rules](https://www.drupal.org/project/rules)**
>
> The Rules module allows site administrators to define conditionally executed actions based on occurring events (known as reactive or ECA rules).

I’ve held off including it in farmOS for a couple of reasons, but I’ve always thought it could be a really useful tool, especially for advanced users. It let’s you configure “rules” via the UI, that happen on specific “events/triggers”, are limited by “conditions”, and then execute specific “actions”.

It’s low-hanging fruit for someone who is hosting farmOS themselves to drop in and play around with.

One of the biggest reasons I haven’t added it “officially” to farmOS is that the Drupal 8 upgrade path has been a question mark. I haven’t looked at it in a while, though, so maybe worth investigating. I think Rules was being refactored from the ground up for Drupal 8, so I figured we’d just wait until we’re on D8 to look at it again. I don’t know if a D7-\>D8 migration path is being worked on.

So in summary: Rules would make it really easy for advanced farmOS users (but not necessarily programmers) to configure triggered actions in the UI. But if you are comfortable with a bit of programming, writing a custom module to do exactly what you want might be simpler (and provide more options).

---

<div class="post-metadata">

**Author:** ![paul121](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@paul121](https://farmos.discourse.group/u/paul121)\
**Post date:** [October 29, 2019, 12:39am UTC](https://farmos.discourse.group/t/schedule-a-log-based-on-a-quantity-value/115/5 "2019-10-29T00:39:54Z")

</div>

Wow!! Awesome. I’ll have to try and “drop it in” and play around. I’m interested in what the UI is like! Seems like a complicated thing to map out, but maybe it’s a bit simpler than I imagine.

@mstenta what else are you hiding from us?? 😃

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [October 29, 2019, 3:32pm UTC](https://farmos.discourse.group/t/schedule-a-log-based-on-a-quantity-value/115/6 "2019-10-29T15:32:33Z")

</div>

Haha the question is: what is the _Drupal community_ hiding? 😉

Re: UI - yes this is probably the weakest part of Rules in Drupal 7, and why I say it might only be usable by “advanced” users. It assumes an understanding of Drupal entity types and systems, and is _very_ generalized for that purpose. It is not designed for farm management specifically by any means.

I would be curious, though, if in Drupal 8 they’ve made any headway on the UI piece. I would love to see the Rules module become more flexible in how it gets integrated into more specific Drupal workflows. eg: wouldn’t it be cool if we could embed a simplified version of the Rules UI somewhere in farmOS, tailored for our purposes?
