/
Automating Sub-Processes

Automating Sub-Processes

Search the IFS Workflow Wiki
 

Back to Tips and Tricks

Automation of Sub-Processes

An upcoming sub-process can be executed automatically given that the previous task is a User/Manual Task. This does NOT work if the previous task is a trigger task. The trigger required to do this varies slightly depending on the scenario. The two possible scenarios are:

  • The main process is going into a sub-process

  • A sub-process has ended, and another sub-process follows immediately after

Scenario 1: Main Process Executes a Sub-Process

//Query to Get Sub-Process UID $sql = "SELECT APP_UID FROM SUB_APPLICATION WHERE APP_PARENT = '".@@APPLICATION."' AND SA_STATUS = 'ACTIVE' AND DEL_THREAD_PARENT = 1"; $rsSql = executeQuery($sql); //Validate Existence if ( count( $rsSql ) > 0 ){ //Sub-Process UID $uid = $rsSql[1]['APP_UID']; //Query to get Sub-Process Index $sqlIndex = "SELECT DEL_INDEX FROM APP_DELEGATION WHERE APP_UID = '$uid' AND DEL_THREAD_STATUS = 'OPEN'"; $rsSqlIndex = executeQuery($sqlIndex); //Validate Existence if( count( $rsSqlIndex ) > 0){ //Sub-Process Index $index = $rsSqlIndex[1]['DEL_INDEX']; //Derivate Case PMFDerivateCase($uid, $index); } }

In order to automate the “Sales Allocation – Streamline Process” Sub-Process, the above trigger needs to be placed in the AFTER ROUTING section of the “Start Task (Streamline)” Task.



Scenario 2: A Sub-Process Ends, Followed by a Second Sub-Process



Inside “Validate Volumes” Sub-Process:



The trigger required to start the “Sales Allocation – Streamline” Sub-Process is placed in the AFTER ROUTING section of the “Revenue Booking Verify Setup” Task, as this is the step immediately BEFORE the “Sales Allocation – Streamline” task.

//Query to Get Sub-Process UID $sql = "SELECT APP_UID FROM SUB_APPLICATION WHERE APP_PARENT = '".@@parentProcessUid."' AND SA_STATUS = 'ACTIVE' AND DEL_THREAD_PARENT = 1"; $rsSql = executeQuery($sql); //Validate Existence if ( count( $rsSql ) > 0 ){ //Sub-Process UID $uid = $rsSql[1]['APP_UID']; //Query to get Sub-Process Index $sqlIndex = "SELECT DEL_INDEX FROM APP_DELEGATION WHERE APP_UID = '$uid' AND DEL_THREAD_STATUS = 'OPEN'"; $rsSqlIndex = executeQuery($sqlIndex); //Validate Existence if( count( $rsSqlIndex ) > 0){ //Sub-Process Index $index = $rsSqlIndex[1]['DEL_INDEX']; //Derivate Case PMFDerivateCase($uid, $index); } }



The difference between these two scenarios is which uid is being used in the first query. In scenario two, the parent process id must be used, because the sub-process (an entirely different process) will end and go back to the parent process after routing. At this point, the trigger will execute (because it placed in the AFTER ROUTING section), so the parent process id needs to be used, instead of the process id of the process where the trigger is in.






Copyright© 2024 IFS AB. Copying prohibited. All rights reserved.