Relative time and date for "Pending till" in Macros

Macros are extremely useful, however the function “Pending till” only allows the entry of absolute dates and times, which makes it useless in almost all cases. It would be great to have the possibility to set “Pending till” to relative times and dates like “in 24 hours”, “in 2 months” ecc.

9 Likes

Absolutely! Also, the same behaviour in scheduler would be useful. I’d love to remind customers (scheduled) of waiting tickets – so I need to set the ‘pending till’ to something like +7 days (so that it reminds again after a week).

1 Like

Edit: I was falsly thinking about Schedulers not Macros, so my comment is invalid.

Summary

be careful with that, this applies on everyrun after 7 days, you still need to workaround this with Tags (just saying :slight_smile: )

Don’t forget triggers :see_no_evil:

cheers

1 Like

I’m not sure what you mean by “everyrun” but for recurring/regular events there could be something like “every N days/months/years”. However I am not sure if that applies to Macros, which - afaik - run a one-time action

Duh! You’re right, sorry… don’t know why I wanted that in Scheduler haha!

Nonetheless: Yes, I am sure I want this feature added to scheduler as well. There are a few customers that always have very urgent thing for us to do and then they constantly forget to provide feedback. So I’d love to have that feature, even if I had to use tags like #remindeveryday or #remindeverymonday. :wink:

2 Likes

We realized this by a (dirty) workaround.
We set the pending till date to somewhat in the far future (01.01.2100).
Running in Linux we now setup a shellscript runing every hour wich searchs via the API for all tickets with the desired date 01.01.2100 und set the date via the API based on the bash date command to “in one week”.

It is tricky and you have to care about errors in the cronjob or the script but now there are two clicks less when setting a ticket to wait.

1 Like

Hello all out there,

maybe if a developer is reading this, she or he could comment if such a feature is (or will be) considered for implementation at all? Basically a relative time like “in N hours|days|months|years” would have to be evaluated once and then the absolute date is entered into the “peding till” field. Even the date command can do this ;-), so it doesn’t seem to be too difficult (implementation wise at least)

We currently have no official plans in adding this feature.
However, this doesn’t mean that it will never have a chance.

If this is a feature you need like yesterday, we can always do a custom development or sponsored feature. :slight_smile:

I would sincerely be interested to know a price idea for this as a sponsored feature. There are a - very few - things that Zammad can’t do of which I think it should be able to it because it “just makes sense” (and I don’t understand why they haven’t been implemented in the first place). This is one of these features. Is there a way to get in touch with you “privately”?

1 Like

Sure!
Feel free to drop us a mail to sales [at] zammad [dot] com and we’ll figure out whats needed to be able to give you feedback. :slight_smile:

Just refer this Thread and mention me (Marcel).
When dropping us a mail, you can also write German if you please. :slight_smile:

So my boss asked for a similar feature here, so I thought I’d take a look at the source and give it a crack.

I’ve never worked with Ruby or rails but now is as good a time as ever, right?

I created a Macro and a Trigger via the interface:
The macro simply sets the Ticket State to ‘Pending Reminder’, and sets the ‘Pending Til’ attribute to a static datetime.
The Trigger is as follows:


Pending Autoclose is simply a custom ticket state.

here are the outputs from the API:
Request:

http://hostname/api/v1/triggers/7

Output:

{
  "id": 7,
  "name": "Auto Close",
  "active": true,
  "condition": {
    "ticket.state_id": {
      "operator": "is",
      "value": "7"
    },
    "ticket.pending_time": {
      "operator": "after (relative)",
      "value": "1",
      "range": "minute"
    }
  },
  "perform": {
    "ticket.state_id": {
      "value": "2"
    }
  },
  "disable_notification": true,
  "note": null,
  "updated_by_id": 23,
  "created_by_id": 23,
  "created_at": "2019-12-10T06:16:57.528Z",
  "updated_at": "2019-12-10T06:16:57.528Z"
}

Request:

http://hostname/api/v1/macros/12

Output:

{
"id": 12,
"name": "eeeeeeeeeee",
"active": true,
"ux_flow_next_up": "none",
"note": "",
"perform": {
    "ticket.state_id": {
    "value": "6"
    },
    "ticket.pending_time": {
    "value": "2019-12-10T21:00:00.000Z"
    }
},
"updated_by_id": 23,
"created_by_id": 23,
"created_at": "2019-12-10T11:28:10.284Z",
"updated_at": "2019-12-10T11:29:23.107Z",
"group_ids": []
}

The first thing I noticed is that the Trigger uses an operator for the condition, so the first thing I tried was to create a custom Macro through the rails console as follows:

Macro.create_if_not_exists(
name:            'Rails Console Sleep',
perform:         {
    'ticket.state_id' => {
    value: Ticket::State.find_by(name: "pending reminder").id,
    },
    'ticket.pending_time' => {
        operator: 'after (relative)',
        value:    7,
        range:    'day',
    },
},
updated_by_id: 1,
created_by_id: 1,
ux_flow_next_up: 'next_task',
note:            'MACRO FROM RAILS CONSOLE',
active:          true,
)

As expected, this does not work. However, it does result in some interesting web client behaviour:
image

After further testing that I won’t go into detail with, it’s apparent that the Macro class has no method for handling non-static entries, so if I was to implement this I’ll need to learn some more.

I do not have too much experience with ruby methods, so I would appreciate some guidance when it comes to updating the Macro class appropriately!

Edit #3:

After a little snooping around, I can see now that currently perform just stores hashes as per its’ inheritance: https://api.rubyonrails.org/classes/ActiveRecord/Store.html

I will try implementing a function at /app/models/macro.rb instead.

1 Like

I created a pull request with an implementation of this feature. https://github.com/zammad/zammad/pull/2862

3 Likes

This topic was automatically closed after 416 days. New replies are no longer allowed.