Intrexx 5.0 makes it possible to start a process even without transaction. This can be useful, for example, when complete data records should be updated. To do so, you need a JavaScript and a Groovy process.
In this sample application, the turnover is listed for every customer. The values are changing constantly and therefore we would like to update the table by the click of a button. The status is a reference value in this application.
Workflow Design

As soon as the process is started, a SQL statement is executed by a Groovy action to update the data records.
1. Generic Eventhandler
Create a new process in the process module of the Portal Manager. Name the process “Process via button“.
Activate „Show Development Tools“.
Add a “Generic Eventhandler“ to the workbench and name it „Update button“. In the dialogue please select “de.uplanet.lucy.server.workflow.eventhandler“ and confirm.
Please select the process element and press the F4 button. Copy the GUID.
Open the process element once again and click “Next“. Now use the green plus symbol and enter “eventGuid“ as the desired name. Copy the GUID into the field.
2. Create the Groovy action
2.1 Add a new Groovy action and drag it onto the existing eventhandler. This way both elements will be linked.
2.2 Rename the Groovy action to “Update status“ and enter the following script:
l_conn = g_dbConnections.systemConnection
def l_stmt = g_dbQuery.prepare
(l_conn, "SELECT LID, FLT_UMSATZ_444061FB FROM XDATAGROUP8AEFA89D")
def l_rs = l_stmt.executeQuery()
l_rs.each
{
def l_recId = it.value(1)
def l_turnover = it.value(2)
if(l_turnover >= 15000)
{
l_typ = 1
}
else if(l_turnover >= 5000 && l_turnover < 15000)
{
l_typ = 2
}
else
l_typ = 3
def l_Update = g_dbQuery.prepare
(l_conn,"UPDATE XDATAGROUP8AEFA89D SET REF_329B933E = ? WHERE LID = ?")
l_Update.setInt(1, l_typ)
l_Update.setInt(2, l_recId)
l_Update.executeUpdate()
l_Update.close()
}
l_rs.close()
l_stmt.close()
2.3 Please confirm by pressing the
OK button and save the process.
Create the JavaScript
On the view-page “All entries“ we need to place a new button called “Update“. This button will call our process by using a JavaScript function.
Please open the JavaScript editor and add the following JavaScript code:
function prozess_start(){
triggerUserWorkflowEvent("C90C388F3129EDA61114955258B660EB76543604");
makeAppRequest("6F1B4237844E1AB893200B103A42FADDCFF94384",
"AC61FF48657D8448D425D933F4BE1A1FFFA417D4", false, false, false);
}
The function
triggerUserWorkflowEvent("") starts the process. The function requires the GUID of the generic eventhandler as a parameter. You can find out the GUID with the help of the F4 button.
The function
makeAppRequest(strApplicationGuid, strPageGuid, false, false, true) refreshes the page after the process has been completed. The following parameters need to be defined:
- Guid: GUID of the application
- Guid: GUID of the view page
- The last Boolean value needs to be set from true to false. This way the desired page will be loaded in the stage (that is the application frame). Otherwise the page will be loaded in a new window.
After saving the JavaScript, the button needs to call the function “Update” by using the OnLoad event.
Now the process can be started via JavaScript.