Create a single object trigger You can create an object trigger using cmd4, e.g.: cmd4 triggerwf -ids 3768 -name MyWorkflow creates an object trigger that calls (via Back4) the workflow 'MyWorkflow' every time the object with id 3768 is modified in any way. Create a single object trigger explicitly specifying the mode You can create an object trigger specifying explicitly the mode e.g.: cmd4 triggerwf -ids 3768 -mode Object -name MyWorkflow creates an object trigger that calls (via Back4) the workflow 'MyWorkflow' every time the object with id 3768 is modified in any way. Note: Object is the default for -mode, so it can be omitted. Create object trigger for multiple objects You can specify multiple objects in a single command, e.g.: cmd4 triggerwf -ids 3768,3770 -name MyWorkflow creates two object triggers that execute the 'MyWorkflow' workflow when either the objects with id 3768 or 3770 are modified. Create object trigger for any object (version 1.5 or newer) You can specify any object in a single command, e.g.: cmd4 triggerwf -mode CheckOut -name TestTrigger defines a trigger that executes the TestTrigger workflow when ANY object is checked-out and checked-in. From build 1.5.1560 it is possible to define triggers (both alert and workflow) that fire when ANY object is modified / checked-out / referenced / de-referenced. Note that there is no '-ids ...' It is possible to restrict the object causing the trigger to fire by object type - e.g. cmd4 triggerwf -mode CheckOut -name TestTrigger -attr folderObject.title executes TestTrigger only when folderObject objcts are checked-out (and checked-in) to modify the 'title' attribute, and cmd4 triggerwf -mode CheckOut -name TestTrigger -attr folderObject.* executes TestTrigger only when folderObject objcts are checked-out (and checked-in). Use with caution: potentially these kind of triggers generate a LOT of alert or workflow execution, on the other hand they have the advantage that it is easier (and possibly lighter) to monitor a lot of objects in this way, because it is not necessary to create a lot of different triggers. Create object attribute trigger The call: cmd4 triggerwf -ids 3768 -attr title -name MyWorkflow creates an object trigger that calls the workflow 'MyWorkflow' every time the attribute 'title' of the object with id 3768 changes values. Note that attribute trigger does not override the object trigger. Create multiple triggers for the same object/attribute If you specify another trigger on the same object/attribute but with a different workflow, it is a separate trigger that does not override any other trigger on the same object/attribute, e.g.: cmd4 triggerwf -ids 3768 -attr title -name MyWorkflow creates a third trigger on the same object. |
To define a referencing or check-out/check-in trigger use the '-mode' option. For referencing: cmd4 triggerwf -ids 9 -mode Referencing -attr folderObject.folderRef -name MyWorkflow defines a trigger that calls the workflow MyWorkflow every time a folder object is added or removed from the folder with id 9. Note that in this case the attribute must be specified, and with its full name. It is possible also to avoid the object id: cmd4 triggerwf -mode Referencing -attr folderObject.folderRef -name TestTrigger defines a trigger that calls the workflow TestTrigger every time a folder object is added or removed from ANY folder. |
The trigger mode ReferencingObject defines triggers that fire when any object referencing the specified object via the specified attribute is modified in any way and still references the specified object after the modifications - i.e. it is not 'sent' to a different container, for example: cmd4 triggerwf -ids 31860 -mode ReferencingObject -attr folderObject.folderRef -name TestTrigger creates a trigger that executes the TestTrigger workflow every time any object referencing the folder with id 31860 is modified. This is available in the version 1.5 or newer. |
For check-out/check-in: cmd4 triggerwf -ids 3714 -mode CheckOut -name TestTrigger defines a trigger that calls the workflow TestTrigger every time the object with id 3714 is checked-out or checked-in, and cmd4 triggerwf -ids 3714 -mode CheckOut -name TestTrigger -attr data defines a trigger that calls the worflow TestTrigger every time the object with id 3714 is checked-out or checked-in for access class 'Content', that is the access class of the object 'data' attribute. It is possible to omit the object ids - e.g. cmd4 triggerwf -mode CheckOut -name TestTrigger defines a trigger that calls the workflow TestTrigger every time any object is checked-out or checked-in; and cmd4 triggerwf -mode CheckOut -name TestTrigger -attr data defines a trigger that calls the workflow TestTrigger every time ANY object with a 'data' attribute is checked-out or checked-in for the access class of this 'data' attribute. When omitting the object ids it is possible to restrict the trigger by object type - e.g. cmd4 triggerwf -mode CheckOut -name TestTrigger -attr folderObject.* defines a trigger that calls the workflow TestTrigger every time any folderObject is checked-out or checked-in; and cmd4 triggerwf -mode CheckOut -name TestTrigger -attr image.data defines a trigger that calls the workflow TestTrigger every time any image is checked-out or checked-in for access class 'Content', that is the access class of the images 'data' attribute. The '-mode' option for object modification triggers is 'Object', so cmd4 triggerwf -ids 3768 -mode Object -name TestTrigger defines a trigger that calls the workflow TestTrigger every time the object with id 3678 is modified. 'Object' is the default for '-mode', so it can be omitted. |
Alert triggers are created using either 'cmd4 triggeralert' or '.../do.ashx?cmd=triggeralert'. Here is a sample cmd4 session defining a trigger and then receiving the corresponding alerts: Cmd4 version 1.2.913.0 debug GN4 command-line client Copyright © 2006 - 2010 Tera Digital Publishing Language en-US
> triggeralert -ids 9 -mode referencing -attr folderObject.folderRef Added one trigger > alerts -on Listening for alerts. > [Trigger folderObject.folderRef referencing obj9]: SendFrom obj3863 [Trigger folderObject.folderRef referencing obj9]: PlaceIn obj3863 The trigger monitors the content of the folder with id 9, the object with id 3863 has been moved out of the folder and then in the folder, resulting in the two alerts. Alert triggers send a new 'Trigger' type of message to the client, containing the details of the trigger and modification (object creation, edit, spike etc.) that caused the alert. |
All the above operations are possible also using 'REST' calls with do.ashx, e.g. ../do.ashx?cmd=triggerwf?ids=3768&name=MyWorkflow creates a trigger executing the workflow MyWorkflow when the object with id 3768 changes etc. |
Important
To all above examples with cmd4 command you may need to add:
-username xxxx -password yyyy
where xxxx is the name of a GN4 user who can logon to system with sufficient permissions to perform this operation and yyyy is the password.
Note: the above connects to the default connection: should you want to specify the connection or server name, see cmd4 examples.
See also
Creating object triggers for calendars and Folders