Once a workflow has been executed, it may succeed, or it may encounter business exceptions that prevent the workflow from being successfully processed. Refer to Workflow Maintenance for Interconnect for details on how to monitor workflow status.
Steps to configure a Workflow
A workflow can be set up as follows:
Log onto the Workflow Portal (see the screenshot below). Set up an employee user with the WorkFlowAdmin role for the Work Flow Admin Portal application. If the user is already configured to work with Employee Portal, then the same username and password will be used by both portals.
Create a workflow using the New Workflows link. See marker 1 in the screenshot below.
Enter workflow details including WorkFlow Name and WorkFlow File Name as shown by markers 2 and 3 in the screenshot above. Note that the WorkFlow File Name cannot be changed via the workflow Portal after it has been saved, so make sure the file name is unique and meaningful to an admin user.
Configure the Workflow content (see the Examples below or refer to the Workflow API).
Set the active flag. When the workflow is ready for use, check off the Active flag (marker 4 above); if it isn’t ready for deployment, leave the workflow inactive by leaving the Active check-box un-checked.
Save workflow changes. When changes are complete, use the Save button to apply these changes (see marker 5 above).
Examples of common workflows that can be used are listed below. For a comprehensive list of other workflow configuration properties, see our Workflow API.
Example: Processing an order from a third-party system
This example shows how to set up a workflow to process orders that are saved to a specific folder as XML files. This would be the type of situation that you might see with order files created by Amazon or Magento systems. An overview of the flow of this scenario is as follows:
- Using a third-party system (such as an Amazon or Magento web store), a customer places an order online. This order cannot be processed until it has been loaded into SAP Business One (B1), so the end goal of this Workflow is for the order to be automatically loaded into B1.
- The third-party system generates an XML order, which needs to be added into B1. This order is saved as an XML file by the third-party application.
- The XML file, which was formatted by the third-party web store, is in the wrong format for SAP Business One. This requires that the XML file be transformed, using XSLT, into a compatible format. To accomplish this, the Workflow Service detects that an XML file exists, and applies the necessary transform. This results in a new XML file that is compatible with B1.
- The newly-transformed XML file (produced by the XSLT applied by the Workflow Service), can now be loaded into B1 by the workflow.
- At this point, the order is in SAP Business One.
To configure a workflow for the above example, perform the following steps:
- Go to the New Workflow page.
My Workflowfor the Workflow Name and
myWorkflow.xmlfor the Workflow File Name.
- Enable the Active check-box.
Enter following XML details for the body of the Workflow:
<?xml version="1.0" encoding="utf-8"?> <WorkFlow xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Trace="ON"> <Header> <Name>Local File Sample</Name> <Description>Testing new XML File Source</Description> <Settings /> </Header> <RetrySettings AllowRetry="true" MaxRetries="3" IntervalInMinutes="5" RetryFolder="RETRY" MaxRetryFailFolder="FAILURE" RetrySuccessFolder="SUCCESS" /> <MessageSource xsi:type="LocalXmlFile" InputFolder="C:\example\incoming" OutputFolder="C:\example\processed" SplitterXPath="" /> <Schedule Type="Polling" WaitTimeInSeconds="10" /> <Branches> <Branch Name="ImportB1ARInvoice"> <Actions> <Action xsi:type="B1Object" B1KeyXpath="BOM" Method="insert" B1ObjectType="oOrders" CopyToFolder="SUCCESS" ExceptionFolder="FAILURE" TransformXSLT="Empty.xslt" /> </Actions> </Branch> </Branches> </WorkFlow>
This creates a workflow that looks for a localXmlFile (set using MessageSource xsi:type) found in the folder C:/example/incoming/ (set using MessageSource InputFolder). The file gets transformed using the XSLT Empty.xslt (set using Action TransformXSLT), found in the Workflow folder /service/xml/xslt/, which is the default location for XSLT files.
Create the custom XSLT file specified in the Action properties. Go to New Workflow XSLTs. Set the Workflow Xslt File to
Empty.xslt(to match the Action TransformXSLT setting of the workflow). Set the contents of the XSLT to the following. Also test out alternative XSLTs, such as the commented section of the code sample:
<!-- THIS XSLT WILL JUST COPY THE XML WITHOUT MODIFICATION --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:param name="RAWDATE"/> <xsl:template match="/"> <xsl:copy-of select="*"/> </xsl:template> </xsl:stylesheet> <!-- USE THIS XSLT AS A SAMPLE FOR TRANSFORMING THE XML <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:param name="RAWDATE"></xsl:param> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="Comments"> <xsl:apply-templates select="@* | *"/> <Comments> Test comment to order <xsl:value-of select="$RAWDATE"/> </Comments> </xsl:template> </xsl:stylesheet> -->
The following files are sample orders taken from the OEC Computers database. order_good.xml is a valid order (for OEC Computers) that will be successfully processed. order_fail_BP_not_exist.xml is an order that is syntactically valid, but contains an unknown BP Card Code, and so will cause a failure. Download WIT_order_samples.zip
Place these two order XML files in the Input Folder (set in the MessageSource InputFolder) C:/example/incoming/. This will cause the Workflow to execute and process the two files.
Note that these samples are for OEC Computers demo database. A valid order XML file can be generated for any system using B1WebAPI. See How to get valid B1 XML samples using B1WebAPI.