Programming

Flow Script

Flow scripting is necessary to use for processing data when you work with “non-deep" connectors like REST/SOAP, MAXIMO, MS Dynamics etc. See further script examples in the Flow Helparrow-up-right.

Machine Step

Script Outputs

When working with Connector Type "Database" machine steps, it is possible to get the outputs of the executed script assigned to the Target Variable of the machine step. The Target Variable field would be disabled for Database Call Type "Script" machine steps by default. To activate this field, first you need to define the output variables in side code.

A good example would be if you are creating a Purchase Order using a script, you will need the created PO No extracted to inform the customer of the new PO. This can be done only be defining a "out" variable at the end.

circle-info

In PL/SQL scripts, out variable needs to be defined starting with a ":" symbol where as for T-SQL scripts, out variable needs to be set starting with a "@" symbol.

BEGIN
  ...
  ...
    
  :out_OrderNo := order_no_;
  
END;

Iterator Option

A full iteration (all included records) is processed as one database transaction, and COMMIT is executed at the end. An error raised on any row causes a stop and rollback of the whole database transaction.

circle-info

An exception should be defined to handle any error in the processing of a record. This is usually at the end of the code written for processing each record. This allows for processing all rows even if a single record fails.

circle-info

Output from the iteration is a flow table which can be used for returning values/results for each row in the iteration.

circle-info

All data must be stored in database tables in order to communicate between iterations.

circle-info

If any additional database operations are needed during executing of first/last row, adjust the data set to add two new columns like "RowNumber" and "NoOfRows". The iterated data set can be adjusted, using flow script, before it is processed.

circle-info

For CRUD workflows, a variable "Type” (with values add, update, delete) is used to distinguish operations. Recognize the appropriate value to handle records in a table.

Oracle PL/SQL

Use of IFS Application Owner

All views and API calls used in Machine Steps needs to be prefixed using the application owner in order to flow to work. Usually "IFSAPP" is the application owner, making our code logics looking like below example.

However, if the customer wishes, they can change the application owner account to a different user other than IFSAPP and disable the IFSAPP account for security reasons. If this happens, all developed flows using IFSAPP will stop working. Further, if you are planning to develop a flow as a template, it should have the ability to work for any support any application owner setup. This needs to be achieved by defining a Global Variable to enter the application owner and using that parameter as the prefix inside the code as shown on below screenshots.

Environment Properties Setup for AppOwner Variable
Assigning the Global Variable to a Flow Variable at Beginning of the Flow
Using AppOwner Variable in the Code
circle-info

AppOwner cannot be called as :AppOwner in view/API prefixes. It has to be done as {AppOwner}.

What to Do

circle-check
circle-check
circle-check
Using Database Values
circle-check
Example for using Remove method to delete handling units
circle-info

All views and API calls used in Machine Steps needs to be called using the application owner in order for the flow to work. Usually "IFSAPP" is the application owner. However there may be a different application owner. Hence always use a global Flow variable (as shown above) to set the application owner.

What to Avoid

triangle-exclamation
triangle-exclamation
triangle-exclamation

Microsoft TSQL

circle-info

To differentiate values from flow variables, use @c_ to indicate that a value is a locally declared variable within the cogwheel.

circle-info

When writing data (Database Call Type: Script), NULL values can cause an issue since flow does not really handle NULL. A way to solve that is to use the following code for all your variables thtat might come as NULL.: if len(@Variable) < 1 set @Variable = NULL for all your variables that might come in as null.

circle-info

If you have Identity enabled on a column (so that SQL assigns a seed value), you can use SCOPE_IDENTITY() to get the newly created record ID.

circle-info

To select from a stored procedure:

Last updated

Was this helpful?