Skip to content

Instantly share code, notes, and snippets.

@icerge
Last active October 11, 2018 21:55
Show Gist options
  • Select an option

  • Save icerge/6fe570fd2c4045cdec2fb87678a79766 to your computer and use it in GitHub Desktop.

Select an option

Save icerge/6fe570fd2c4045cdec2fb87678a79766 to your computer and use it in GitHub Desktop.
Scheduling a script run in run-time

Pattern: I'd like something to happen in future.

It's a subset of the patter I'd like some event to happen in future. It covers the case of conditional execution: event + script action.

In the sample below I'd like to send reminder email (of course, if it is still valid).

var x = new ScheduleOnce();
x.setDocument(current);
x.setLabel("Approval reminder " + current.getDisplayValue());
x.setTime(/*now + 4 days*/);
var script = [];
script.push("var g = new GlideRecord('sysapproval_approver');");
script.push("g.get('" + current.getUniqueValue() + "');");
script.push("gs.eventQueue('reminder.email', g);");

gs.print(script);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment