Managing V6 workflow for classes
The workflow engine used in V6 is based on V6 development models such as "V6 objects" (described by GESAOB function).
In V7 and the following upgrades, a new type of development uses classes and representations in object mode. The V6 workflow engine does not handle events on classes or representations. This will be possible in a future upgrade with a new workflow engine. Currently, it is possible, from a V7 code associated with a class, to trigger a workflow event through dedicated APIs.
These APIs are located in ASYRWRKCLASSIC library. Their execution is based on batch tasks. This means that using these APIs to trigger a V6 workflow event execution from code associated with a class creates a batch task request. The batch server executes V6 code to handle the workflow.
The corresponding batch task is called AWRKCLA.
Some limitations exist in the workflow event called in that way:
- Only 3 event types are managed: Miscellaneous, Object, and Manual.
- It is not possible, in a modification workflow called from a class, to have access to the previous values in [F] classes and to the modified values in [M] classes. The only entity you have is the modified record.
Call a workflow event
The function is located in the ASYRWRKCLASSIC library. Its definition is the following:
Funprog WORKFLOW(ACTX,TYPEVT,CODEVT,OPERAT,CLEOBJ,REQUEST,MESSAGE)
Variable Instance ACTX Using =[V]CST_C_NAME_CLASS_CONTEXT : # Context where the errors messages are stored
Value Integer TYPEVT : # Workflow type event (local menu #988) : only 1,2,10 are possible
Value Char CODEVT : # Event code
Value Char OPERAT : # Operation (operation codes C=creation, M=modification, or a "button" code)
Value Char CLEOBJ : # Object key for object event
Variable Integer REQUEST : # Returns the ID for the batch request created
Variable Char MESSAGE : # Message returned by the workflow post
This function has to be called in the scripts associated with the class or the representation to implement a workflow call. For example, for the TABCOUNTRY class, if you want to call all the workflow events based on a modification for object TCY (the V6 object that stores countries), then in the TABCOUNTRY_CSTD script, on the 'AUPDATE_AFTER' event, you add the following code:
$AUPDATE_AFTER
Local Integer REQNUM,TYPEVT,STAT
Local Char CODEVT(30)
Local Char OPERAT(30)
Local Char MSG(250),CLEOBJ(250)
TYPEVT=2 : # Object based event
CODEVT="TCY" : # The object is TCY
OPERAT="M" : # Modification
CLEOBJ=this.CRY : # Current key
STAT = func ASYRWRKCLASSIC.WORKFLOW(this.ACTX,TYPEVT,CODEVT,OPERAT,CLEOBJ,REQNUM,MSG)
Return
If, for the TABCOUNTRY class, you want to call all the workflow events based on creation for object TCY (the V6 object that stores countries), then in the TABCOUNTRY_CSTD script, on the 'AINSERT_AFTER' event, you add the following code:$AINSERT_AFTER
Local Integer REQNUM,TYPEVT,STAT
Local Char CODEVT(30)
Local Char OPERAT(30)
Local Char MSG(250),CLEOBJ(250)
TYPEVT=2 : # Object based event
CODEVT="TCY" : # The object is TCY
OPERAT="C" : # Creation
CLEOBJ=this.CRY : # Current key
STAT = func ASYRWRKCLASSIC.WORKFLOW(this.ACTX,TYPEVT,CODEVT,OPERAT,CLEOBJ,REQNUM,MSG)
Return
Call a manual workflow event
The function is located in the ASYRWRKCLASSIC library. The call is simplified for manual workflows so there are fewer parameters to send:Funprog WORKMANUAL(ACTX,CODE,FILTER,SIMUL,REQUEST,MESSAGE)
Variable Instance ACTX Using =[V]CST_C_NAME_CLASS_CONTEXT : # Context where the errors messages are stored
Value Char CODE : # Event code
Value Char FILTER : # Filter
Variable Integer REQUEST : # Returns the ID of the batch request created
Variable Char MESSAGE : # Message returned by the workflow post
Extended workflow event call
The function is located in the ASYRWRKCLASSIC library. This call has additional parameters and is supplied for compatibility reasons only. Some parameters are no longer used:Funprog WORKPLUS(ACTX,TYPEVT,CODEVT,OPERAT,CLEOBJ,CODE,SIMUL,DIFFERE,TYPDEC,GRPDEB,REQUEST,MESSAGE)
Variable Instance ACTX Using =[V]CST_C_NAME_CLASS_CONTEXT : # Context where the errors messages are stored
Value Integer TYPEVT
Value Char CODEVT
Value Char OPERAT
Value Char CLEOBJ
Value Char CODE : # Workflow (in case of W button and manual workflow)
Value Integer SIMUL : # Allows to simulate or to generate a manual workflow
Value Integer DIFFERE : # delayed message sending (object creation / update transaction)
Value Integer TYPDEC : # Workflow triggering before/after update [F] in object workflow - obsolete
Variable Char GRPDEB : # first group chrono (used for delayed send)
Variable Integer REQUEST
Variable Char MESSAGE
Note
The workflow events based on V6 objects or V6 events continue to be executed from the object if classic code is used. The difference between classic execution and class/representation execution is that in classic code, the execution is always triggered; while in class/representation, this execution is only triggered if the previous API has been integrated on the correct events in the scripts associated with classes or representation.
If you want to prevent a workflow event from being executed in classic mode on an object, the value of GFONCTION can be tested. It is only filled for a classic execution with the GESXXX value, where XXX is the object code.