Árvore de páginas

7.1. Objective

Enable a Metadata form to interact with the workflow engine at Fluig, performing operations such as:

    • Starting a new process (start request)

    • Cancel a request

    • Change the deadline date of a task

    • Change the task comments

    • Return the value of a workflow form field

    • Move request to next activity

    • Select user(s) and advance automatic activity

    • Assume a task

    • Obtain the attachments of a request

    • Return the activity number where the request is

    • Return the number of the next activity in a request

    • Return activity details available for selection

    • Return users who can perform a current task in a request

    • Return the processes the user can initiate in a request

    • Returns the users available in opening a request

    • Searches processes available for initialization

Interaction with the wokflow engine will be made via ABLScript codes using the command ECM-REQUEST-SERVICE(). This command will perform calls to the WorkflowEngineService, as shown in the following diagram:

Figure 6.1.a

7.2. Programming Guide

Syntax for command ECM-REQUEST-SERVICE:

variable = ECM-REQUEST-SERVICE(serviceID, operationId, [param1, param2, param3, ...]).

 

Where:

  • variable: variable of the CHARACTER type which will receive the command execution response. The answer may come as a single character, which can be converted to another type through functions DECIMAL(), INTEGER() or DATE(). Or it may be a JSON character that will be converted to a TEMP-TABLE through the JSON function - DECODE().

  • serviceID: character with the ID of the service to be performed in Fluig. To meet the requirements defined in this document, the serviceId="WORKFLOW" should be used. In the future, methods may be implemented for accessing other services at Fluig, as for example DocumentService or FolderService.

  • operationID: it identifies the operation (method) to be performed in WorkflowEngineService. Example: “START-PROCESS”.

  • param1, param2, ...: list of parameters to be sent to the service.

Operations

Operation ID: START-PROCESS

Description: Start a process.

Return:TempTable

Parameters:

Name Type Description Details
processId character Process code  
colleagueIds character Users who will receive the task use character in format: "colab1,colab2,colab3"
activityNumber int Activity number  
comments character Comments  
completeTask logical Indicates if the task must be completed (true) or only saved (false)  
ttAttachments TempTable Request attachments

DEFINE TEMP-TABLE ttAttach

    FIELD documentId AS INTEGER

    FIELD documentVersion AS INTEGER

    FIELD description AS CHARACTER

    FIELD filename AS CHARACTER

    FIELD filepath AS CHARACTER

    FIELD principal AS LOGICAL.

ttCardData TempTable Form data

DEFINE TEMP-TABLE ttCard

    FIELD fieldName AS CHARACTER

    FIELD fieldValue AS CHARACTER.

ttAppointment TempTable Task annotations

DEFINE TEMP-TABLE ttAppointment

    FIELD appointmentDate AS CHARACTER

    FIELD appointmentSeconds AS INTEGER

    FIELD appointmentSequence AS INTEGER.

managerMode logical Indicates whether the user is initiating the request as a process manager.  

 

Operation ID: CANCEL-PROCESS

Description: Cancels a process.

Return: character

Parameters:

Name Type Description
processInstanceId integer Process code
cancelText

character

Cancellation comments


Operation ID: SET-DUE-DATE

Description: Changes the deadline date for the task.

Return: character

Parameters:

Name Type Description
processInstanceId integer Process code
threadSequence  integer

Indicates if there is any parallel activity in the process. If there are none, the value is 0 (zero),

if there are any, this value can range from 1 to infinity depending on the amount of parallel

activities existing in the process. 

newDueDate character  New deadline date for the task. 
timeInSeconds integer Task time in seconds.

 

Operation ID: SET-TASK-COMMENTS

Description: Changes the results of the task.

Return: character

Parameters:

Name Type Description
processInstanceId  integer Process code 
threadSequence  integer

Indicates if there is any parallel activity in the process. If there are none, the value is 0 (zero),

if there are any, this value can range from 1 to infinity depending on the amount of

parallel activities existing in the process. 

comments character Comment 

 

Operation ID: GET-CARD-VALUE

Description: Returns the value of a form field.

Return: character

Parameters:

Name Type Description
processInstanceId integer Process code
fieldName character Name of form field

 

Operation ID: SAVE-AND-SEND-TASK

Description: Moves the request to the next activity.

Return: TempTable

Parameters:

Name Type Description Details
processInstanceId integer Process code  
colleagueIds character Users who will receive the task use character in format: "colab1,colab2,colab3"
activityNumber integer Activity number  
comments character Comments  
completeTask logical Indicates if the task must be completed (true) or only saved (false)  
ttAttachments TempTable Request attachments

DEFINE TEMP-TABLE ttAttach

    FIELD documentId AS INTEGER

    FIELD documentVersion AS INTEGER

    FIELD description AS CHARACTER

    FIELD filename AS CHARACTER

    FIELD filepath AS CHARACTER

    FIELD principal AS LOGICAL.

ttCardData TempTable Form data

DEFINE TEMP-TABLE ttCard

    FIELD fieldName AS CHARACTER

    FIELD fieldValue AS CHARACTER.

ttAppointment TempTable Task annotations

DEFINE TEMP-TABLE ttAppointment

    FIELD appointmentDate AS CHARACTER

    FIELD appointmentSeconds AS INTEGER

    FIELD appointmentSequence AS INTEGER.

managerMode logical

Indicates whether the user is initiating the request as a

process manager.

 
threadSequence integer

Indicates if there is any parallel activity in the process. If there are no activities,

the value is 0 (zero), if there are any, this value can range

from 1 to infinity depending on the amount of parallel

activities existing in the process.

 

 

Operation ID: SAVE-AND-SEND-TASK-BY-REPLACEMENT

Description: Moves the request to the next activity using substitute user.

Return: TempTable

Parameters:

Name Type Description Details
processInstanceId integer Process code  
colleagueIds character Users who will receive the task use character in format: "colab1,colab2,colab3"
activityNumber integer Activity number  
comments character Comments  
completeTask logical Indicates if the task must be completed (true) or only saved (false)  
ttAttachments TempTable Request attachments

DEFINE TEMP-TABLE ttAttach

    FIELD documentId AS INTEGER

    FIELD documentVersion AS INTEGER

    FIELD description AS CHARACTER

    FIELD filename AS CHARACTER

    FIELD filepath AS CHARACTER

    FIELD principal AS LOGICAL.

ttCardData TempTable Form data

DEFINE TEMP-TABLE ttCard

    FIELD fieldName AS CHARACTER

    FIELD fieldValue AS CHARACTER.

ttAppointment TempTable Task annotations

DEFINE TEMP-TABLE ttAppointment

    FIELD appointmentDate AS CHARACTER

    FIELD appointmentSeconds AS INTEGER

    FIELD appointmentSequence AS INTEGER.

managerMode logical

Indicates whether the user is initiating the request as a

process manager.

 
threadSequence integer

Indicates if there is any parallel activity in the process. If

there are no activities, the value is 0 (zero), if there are any, this value

can range from 1 to infinity depending on the amount of

parallel activities existing in the process.

 
replacementId character Registration of the substitute user  

 

Operation ID: SET-AUTOMATIC-DECISION

Description: Selects user(s) and advance automatic activity.

Return: TempTable

Parameters:

Name Type Description Details
processInstanceId integer Process code  
autoTaskNum integer Automatic activity number  
taskNum integer Current activity number  
condition integer Automatic activity condition number  
colleagueIds character Users who will receive the task use character in format: "colab1,colab2,colab3"
comments character Comments  
managerMode logical Indicates if the user is performing the task as a process manager  
threadSequence integer

Indicates if there is any parallel activity in the process. If there are none, the value is 0 (zero),

if there are any, this value can range from 1 to infinity depending on the amount of

parallel activities existing in the process.

 

 

Operation ID: TAKE-PROCESS-TASK

Description: Assumes a task.

Return: character

Parameters:

Name Type Description
processInstanceId integer Process code
threadSequence integer

Indicates if there is any parallel activity in the process. If there are none, the value is 0 (zero),

if there are any, this value can range from 1 to infinity depending on the amount of

parallel activities existing in the process.

 

Operation ID: TAKE-PROCESS-TASK-BY-REPLACEMENT

Description: Assumes a task using substitute user.

Return: character

Parameters:

Name Type Description
processInstanceId integer Process code
threadSequence integer

Indicates if there is any parallel activity in the process. If there are none, the value is 0 (zero),

if there are any, this value can range from 1 to infinity depending on the amount of

parallel activities existing in the process.

replacementId character Registration of the substitute user.

 

Operation ID: GET-ATTACHMENTS

Description: Returns the request attachments

Return: TempTable

Parameters:

Name Type Description
processInstanceId integer Process code

 

Operation ID: GET-ALL-ACTIVE-STATES

Description: Returns the activity number where the request is.

Return: TempTable

Parameters:

Name Type Description
processInstanceId integer Process code

 

Operation ID: GET-ACTUAL-THREAD

Description: Returns the thread sequence of a request.

Return: TempTable

Parameters:

Name Type Description
processInstanceId integer Process code
stateSequence integer State sequence

 

Operation ID: GET-AVAILABLE-STATES

Description: Returns the number of the next activity in a request.

Return: TempTable

Parameters:

Name Type Description
processId character Process code
processInstanceId integer Process code
threadSequence integer

Indicates if there is any parallel activity in the process. If there are none, the value is 0 (zero),

if there are any, this value can range from 1 to infinity depending on the amount of

parallel activities existing in the process.

 

Operation ID: GET-AVAILABLE-STATES-DETAIL

Description: Returns details on the activities available for selection.

Return: TempTable

Parameters:

Name Type Description
processId character Process code
processInstanceId integer Process code
threadSequence integer

Indicates if there is any parallel activity in the process. If there are none, the value is 0 (zero),

if there are any, this value can range from 1 to infinity depending on the amount of

parallel activities existing in the process.

 

Operation ID: GET-AVAILABLE-USERS

Description: Returns users who can perform a current task in a request.

Return: TempTable

Parameters:

Name Type Description
processInstanceId integer Process code
taskNumber integer Activity number
threadSequence integer

Indicates if there is any parallel activity in the process. If there are none, the value is 0 (zero),

if there are any, this value can range from 1 to infinity depending on the amount of

parallel activities existing in the process.

 

Operation ID: GET-INSTANCE-CARD-DATA

Description: Returns the field values of form.

Return: TempTable

Parameters:

Name Type Description
processInstanceId integer Process code

 

Operation ID: GET-AVAILABLE-PROCESS

Description: Returns the processes the user can initiate in a request.

Return: TempTable


Operation ID: GET-AVAILABLE-USERS-START

Description: Returns the users available in opening a request.

Return: TempTable

Parameters:

Name Type Description
processId character Process code
taskNum integer Activity number
threadSequence integer

Indicates if there is any parallel activity in the process. If there are none, the value is 0 (zero),

if there are any, this value can range from 1 to infinity depending on the amount of

parallel activities existing in the process.

 

Operation ID: SEARCH-PROCESS

Description: Searches processes available for initialization.

Return: TempTable

Parameters:

Name Type Description
content character Name of the process to be searched
favorite logical Search in the favorite list or the standard list.

 

Usage example

Find below an example of a Datasul Metadata Freeform form that performs some operations with the ECM-REQUEST-SERVICE command.

Figure 6.2.a

Figure 6.2.a shows a form that when loaded performs the search for available processes for the logged user and presents them in a grid. In Figure 6.2.a, the process "Proc3" was selected, which has an associated form. The form fields and annotation data were informed. Finally, the user clicked the START-PROCESS button, creating a new instance of the process, resulting in the process ID 119.

Below, several form scripts are presented.

varDefinition

/* Start WIDGET-HANDLE - Do not edit, use CTRL + SHIFT + H */
DEFINE VARIABLE txtComment AS WIDGET-HANDLE.
DEFINE VARIABLE txtDescricao AS WIDGET-HANDLE.
DEFINE VARIABLE canvasCard AS WIDGET-HANDLE.
DEFINE VARIABLE txtCodigo AS WIDGET-HANDLE.
DEFINE VARIABLE lblProcList AS WIDGET-HANDLE.
DEFINE VARIABLE canvasAppointment AS WIDGET-HANDLE.
DEFINE VARIABLE lblProcInstId AS WIDGET-HANDLE.
DEFINE VARIABLE lblAttach AS WIDGET-HANDLE.
DEFINE VARIABLE txtProcInstId AS WIDGET-HANDLE.
DEFINE VARIABLE lblApp AS WIDGET-HANDLE.
DEFINE VARIABLE gridProcess AS WIDGET-HANDLE.
DEFINE VARIABLE dtf AS WIDGET-HANDLE.
DEFINE VARIABLE canvasAttach AS WIDGET-HANDLE.
DEFINE VARIABLE txtSec AS WIDGET-HANDLE.
DEFINE VARIABLE lblForm AS WIDGET-HANDLE.
/* End WIDGET-HANDLE */

DEFINE VARIABLE resp AS CHARACTER.
DEFINE VARIABLE ttResult AS TEMP-TABLE.

Canvas.creationComplete

PROCESS-WAIT(TRUE).
/* Style arrow for some components */
CALLFUNCTION(lblProcList, "setStyle", "fontSize", 11).
CALLFUNCTION(lblProcList, "setStyle", "fontWeight", "bold").
CALLFUNCTION(lblProcInstId, "setStyle", "fontSize", 11).
CALLFUNCTION(lblProcInstId, "setStyle", "fontWeight", "bold").
CALLFUNCTION(canvasAttach, "setStyle", "backgroundColor", "#d9dbe1").
CALLFUNCTION(lblAttach, "setStyle", "fontSize", 11).
CALLFUNCTION(lblAttach, "setStyle", "fontWeight", "bold").
CALLFUNCTION(canvasCard, "setStyle", "backgroundColor", "#d9dbe1").
CALLFUNCTION(lblForm, "setStyle", "fontWeight", "bold").
CALLFUNCTION(canvasAppointment, "setStyle", "backgroundColor", "#d9dbe1").
CALLFUNCTION(lblApp, "setStyle", "fontWeight", "bold").
 
/* Obtains the processes available for the user */
resp = ECM-REQUEST-SERVICE("WORKFLOW", "GET-AVAILABLE-PROCESSES").
 
if RESULT-WITH-ERROR(resp) THEN DO:
    MESSAGE resp
        VIEW-AS ALERT-BOX ERROR
        TITLE "Error while running GET-AVAILABLE-PROCESS".
ELSE DO:
    ttResult = JSON-DECODE(resp).
    gridProcess:QUERY-OPEN(ttResult).
END.
PROCESS-WAIT(FALSE).

btoStartProcess.click

DEFINE VARIABLE idx AS INTEGER.
DEFINE VARIABLE processId AS CHARACTER.
DEFINE VARIABLE procComment AS CHARACTER.
DEFINE VARIABLE aux AS CHARACTER.
DEFINE VARIABLE once AS LOGICAL INITIAL true.
DEFINE VARIABLE dt AS DATE.
DEFINE VARIABLE iaux AS INTEGER.
 
/* Obtains the process selected on the Grid */
idx = GETPROPERTY(gridProcess, "selectedIndex").
ttResult:SET-CURRENT(idx).
processId = ttResult.processId.
 
/* Obtains the comment */
procComment = txtComment:SCREEN-VALUE.
 
/* Obtains files to attach from the upload component */
DEFINE VARIABLE upload AS WIDGET-HANDLE.
DEFINE TEMP-TABLE ttFiles
   FIELD name AS CHARACTER
   FIELD type AS CHARACTER
   FIELD appServerPath AS CHARACTER
   FIELD jbossPath AS CHARACTER
   FIELD size AS DECIMAL.
ttFiles = GETPROPERTY(upload,"files").
 
/* Prepares Temp-Table for attachments */
DEFINE TEMP-TABLE ttAttach
   FIELD documentId AS INTEGER
   FIELD documentVersion AS INTEGER
   FIELD description AS CHARACTER
   FIELD filename AS CHARACTER
   FIELD filepath AS CHARACTER
   FIELD principal AS LOGICAL.
 
FOR EACH ttFiles:
    CREATE ttAttach.
    ttAttach.documentVersion = 1000.
    ttAttach.description = ttFiles.name.
    ttAttach.filename = ttFiles.name.
    ttAttach.filepath = ttFiles.jbossPath.
    IF once THEN DO:
       ttAttach.principal = true.
       once = false.
    END.
END.
 
/* Prepares Temp-Table with values from the form */
DEFINE TEMP-TABLE ttCard
   FIELD fieldName AS CHARACTER
   FIELD fieldValue AS CHARACTER.
 
CREATE ttCard.
ttCard.fieldName = "A1_CODIGO".
aux = txtCodigo:SCREEN-VALUE.
ttCard.fieldValue = aux.
 
CREATE ttCard.
ttCard.fieldName = "A1_DESCRICAO".
aux = txtDescricao:SCREEN-VALUE.
ttCard.fieldValue = aux.
 
/* Prepares Temp-Table with values from the Annotation */
DEFINE TEMP-TABLE ttAppointment
   FIELD appointmentDate AS CHARACTER
   FIELD appointmentSeconds AS INTEGER
   FIELD appointmentSequence AS INTEGER.
 
aux = txtSec:SCREEN-VALUE.
IF aux <> "" THEN DO:
   CREATE ttAppointment.
   dt = GETPROPERTY(dtf, "selectedDate").
   aux = STRING(dt, "99/99/9999").
   aux = aux + " 00:00:00".
   ttAppointment.appointmentDate = aux.
   iaux = INTEGER(txtSec:SCREEN-VALUE).
   ttAppointment.appointmentSeconds = iaux.
   ttAppointment.appointmentSequence = 1.
END.
/* Starts the process */
resp = ECM-REQUEST-SERVICE("WORKFLOW", "START-PROCESS", processId, "framework", 2, procComment, true, ttAttach, ttCard, ttAppointment, false).
 
IF RESULT-WITH-ERROR(resp) THEN DO:
    MESSAGE resp
        VIEW-AS ALERT-BOX ERROR
        TITLE "Error when running START-PROCESS".
ELSE DO:
    txtProcInstId:SCREEN-VALUE = resp.
END.

 

btoCancelProcess.click

DEFINE VARIABLE processInstId AS INTEGER.
processInstId = INTEGER(txtProcInstId:SCREEN-VALUE).
 
/* If cancellation Ok, it returns ' true ', if not, it returns the error message */
resp = ECM-REQUEST-SERVICE("WORKFLOW", "CANCEL-PROCESS", processInstId, "Finaliza processo!").
 
IF RESULT-WITH-ERROR(resp) THEN DO:
    MESSAGE resp
        VIEW-AS ALERT-BOX ERROR
        TITLE "Error while running GET-AVAILABLE-PROCESS".
ELSE DO:
    MESSAGE "Process successfully cancelled!"
        VIEW-AS ALERT-BOX INFORMATION
        TITLE "CANCEL-PROCESS".
    txtProcInstId:SCREEN-VALUE = "".
END.

btoGetCardData.click

DEFINE VARIABLE procInstId AS INTEGER.
procInstId = INTEGER(txtProcInstId:SCREEN-VALUE).
 
/* Obtains one field at a time: GET-CARD-VALUE
resp = ECM-REQUEST-SERVICE("WORKFLOW", "GET-CARD-VALUE", procInstId, "A1_CODIGO").
 
IF RESULT-WITH-ERROR(resp) THEN DO:
    MESSAGE resp
        VIEW-AS ALERT-BOX ERROR
        TITLE "Error when running GET-CARD-VALUE".
ELSE DO:
    txtCodigo:SCREEN-VALUE = resp.
END.
 
resp = ECM-REQUEST-SERVICE("WORKFLOW", "GET-CARD-VALUE", procInstId, "A1_DESCRICAO").
 
IF RESULT-WITH-ERROR(resp) THEN DO:
    MESSAGE resp
        VIEW-AS ALERT-BOX ERROR
        TITLE "Error when running GET-CARD-VALUE".
ELSE DO:
    txtDescricao:SCREEN-VALUE = resp.
END. */
 
/* Obtains all fields from the form: GET-INSTANCE-CARD-DATA */
resp = ECM-REQUEST-SERVICE("WORKFLOW", "GET-INSTANCE-CARD-DATA", procInstId).
 
DEFINE VARIABLE ttCard AS TEMP-TABLE.
DEFINE VARIABLE fieldName AS CHARACTER.
DEFINE VARIABLE fieldValue AS CHARACTER.
 
IF RESULT-WITH-ERROR(resp) THEN DO:
    MESSAGE resp
        VIEW-AS ALERT-BOX ERROR
        TITLE "Error when running GET-INSTANCE-CARD-DATA".
ELSE DO:
    ttCard = JSON-DECODE(resp).
    FOR EACH ttCard:
        fieldName = ttCard.fieldName.
        fieldValue = ttCard.fieldValue.
 
        IF fieldName = "A1_CODIGO" THEN DO:
            txtCodigo:SCREEN-VALUE = fieldValue.
        END.
        IF fieldName = "A1_DESCRICAO" THEN DO:
            txtDescricao:SCREEN-VALUE = fieldValue.
        END.
    END.
END.

btoAvailableUsers.click

DEFINE VARIABLE procInstId AS INTEGER.
procInstId = INTEGER(txtProcInstId:SCREEN-VALUE).
/* Obtains a user list for the task */
resp = ECM-REQUEST-SERVICE("WORKFLOW", "GET-AVAILABLE-USERS", procInstId, 2, 0).
 
DEFINE VARIABLE ttUsers AS TEMP-TABLE.
IF RESULT-WITH-ERROR(resp) THEN DO:
    MESSAGE resp
        VIEW-AS ALERT-BOX ERROR
        TITLE "Error when running GET-AVAILABLE-USERS".
ELSE DO:
    ttUsers = JSON-DECODE(resp).
    FOR EACH ttUsers:
        DISPLAY ttUsers.user.
    END.
END.

btoTakeTask.click

DEFINE VARIABLE procInstId AS INTEGER.
/* Obtains the process instance Id */
procInstId = INTEGER(txtProcInstId:SCREEN-VALUE).
/* Assumes current task */
resp = ECM-REQUEST-SERVICE("WORKFLOW", "TAKE-PROCESS-TASK", procInstId, 0).
IF RESULT-WITH-ERROR(resp) THEN DO:
    MESSAGE resp
        VIEW-AS ALERT-BOX ERROR
        TITLE "Error when running TAKE-PROCESS-TASK".
ELSE DO:
    DISPLAY resp.
END.
  • Sem rótulos