scheduleNewSystemAction
Updated pdexter 2022-10-22
Schedules a System Action to occur in the future, which runs a RuleSet.
(server-side function)
Syntax
ft3.scheduleNewSystemAction( data, checkDate, rulesetName, user, function(err, systemActionDocument ) {
...
})
Part | Description |
---|---|
document | data | data to pass to ruleset; should contain a reference (documentId) of the document being processed. This will be received by the ruleset as ntf.document. |
checkDate | the date-time the system action should run |
rulesetName | the Name of the ruleset |
user | the user to use for the system action |
systemActionDocument | the newly created system action document |
err | any error that occurred; null if successful |
Example
var ft3 = ntf.scope;
var nbrMinutesToWait = 15;
var checkDate = new Date();
var templateId = '944e24fb8cf0a381942b3e77';
checkDate = ft3.moment().add(nbrMinutesToWait, 'minute');
// Create data to pass
var dataToPass = {
documentId : ntf.document.documentId,
accessCode : '55435444186-73460',
note : 'document truncated - query for current'
};
ft3.scheduleNewSystemAction(dataToPass, checkDate, 'Task-Direct-LoneOvertime',
ntf.user, function(err, doc) {
if (err) {
ntf.logger.info(err.message);
}
else if (doc) {
logger.info('New system action created: ' + doc.documentId);
}
...
});
return;
Tip
The first argument document/data traditionally contained the full document object, however this is not necessary, and even counterproductive.
When passing the document/data to this method, only the reference documentId to the document is required. In general, the target ruleset should query for the current document from the database anyway, using documentId.
This will avoid any issues with using an out of date version of the document in the target ruleset.