How to create a process in ECM using Microsiga Protheus
Processes can be created in ECM through the tool itself. Below we describe how to accomplish that using Microsiga Protheus customization.
In order to create a process from Microsiga Protheus, we can use the WF Wizard from the configurator module, or create a customization.
Below we describe how to create using a customization
- Configure the integration for the workflow between Protheus and ECM in the Configurator, in the Environment > Totvs ECM > WF Wizard option
- Use the FWECMProcess function to create and/or update the process in ECM, as shown below:
#include "totvs.ch"
User Function ProcCliente()
Local cProcessId := "CLIENT"
Local cDescription := "Customer file"
Local cInstruction := "Process use instructions"
Local nFormId := 22 // card index id added to ECM in previous step
Local aStates := Array(4,6) // process activities in sequence for automatic flow creation
Local aEvents := Array(1,2) // events that will be customized for the process
Local aProperties := Array(1,2) // properties that will be used in process event scripts
Local aError
aStates[1][1] := "Start" // activity
aStates[1][2] := "" // description
aStates[1][3] := "" // instructions
aStates[1][4] := 60 // conclusion deadline in seconds
aStates[1][5] := 0 // assignment mechanism (zero for none, 1 for group or 2 for user)
aStates[1][6] := "" // group or user code in ECM in case the assignment mechanism is different from zero
aStates[2][1] := "Review" // activity
aStates[2][2] := "Review of customer file" // description
aStates[2][3] := "Review file information" // instructions
aStates[2][4] := 60 // conclusion deadline in seconds
aStates[2][5] := 0 // assignment mechanism (zero for none, 1 for group or 2 for user)
aStates[2][6] := "" // group or user code in ECM in case the assignment mechanism is different from zero
aStates[3][1] := "End" // activity
aStates[3][2] := "Confirm file" // description
aStates[3][3] := "" // instructions
aStates[3][4] := 60 // conclusion deadline in seconds
aStates[3][5] := 0 // assignment mechanism (zero for none, 1 for group or 2 for user)
aStates[3][6] := "" // group or user code in ECM in case the assignment mechanism is different from zero
aEvents[1][1] := "beforeTaskSave"
// JavaScript language script
aEvents[1][2] := 'function beforeTaskSave(colleagueId,nextSequenceId,userList){'+;
'var A1_COD = hAPI.getCardValue("A1_COD");'+;
'if (A1_COD == ""){'+;
' throw "Code field is mandatory"'+;
'}'+;
'}'
aProperties[1][1] := "TABLE" // property name
aProperties[1][2] := "SA1" // value
FWECMProcess(cProcessId, cDescription, cInstruction, nFormId, aStates, aEvents, aProperties)
If FWWFIsError()
aError := FWWFGetError()
MsgStop(aError[2])
Else
MsgInfo("Process updated successfully")
EndIf
Return