This is the starting element containing one or more actions that will be executed as part of the workflow integration.

<Action> Base Attributes

<Action> Base Attributes
Attribute Description
RelatedInfoNode When this attribute is specified the result of the action (if it is valid XML) is appended to the message being processed in a separate XML section called <RelatedInformation>. For example, this could be used to retrieve customer information from a system like Magento while processing sales orders. This customer information would then be available to process via XSLT.
TransformXSLT This attribute specifies an XSLT that will be applied to the message that is being processed by the Action.
TransformRoot (optional) This attribute is used when the TransformXSLT is specified. It is an optional value to instruct the XSLT transform to begin at a specific XElement instead of the document root.
CopyToFolder (optional) Name of message folder to use after successful processing of the new message in the queue. Leave this attribute empty if you only want messages created upon failure. This creates a copy of the message at the time of processing and saves it.
ExceptionFolder Name of message folder to use when creating the new message in the queue upon failure. This creates a copy of the message at the time of processing and saves it.

<Action> Child Elements

<ActionParameters> contain sub-elements <Parameter>, as shown in the code sample below.

  • <Parameter> - This allows you to define a parameter value that will be passed into the executing action.
    • Name - Name of the parameter.
    • ElementName - (optional) Optionally set the starting XML element to select your comparison XPath. For example, set this value to RelatedInformation and all XPaths will be executed against that node.
    • ParameterXpath - XPath into the value of parameter.
<ActionParameters>
    <Parameter Name="b1document" WorkFlowMessageKey="true"/>
    <Parameter Name="TableName" Value="ODLN"/>
    <Parameter Name="magcustId" ElementName="Order_Info" ParameterXpath="//callReturn/customer_id" />
</ActionParameters>

<Action type=”B1Query”>

This type of action is used to execute a B1WebAPI query against the Business One database and return values to the workflow processor. The B1Query is typically used to populate the <RelatedInformation> element of a Message being processed with extra parameters or details.

In the example below the results from executing the DoesMagentoBPExist query via the B1WebAPI will be added to a node called B1BPLookup and appended to the Related Information element.

<Action xsi:type="B1Query" RelatedInfoNode="B1BPLookup" QueryName="DoesMagentoBPExist">
    <ActionParameters>
        <Parameter Name="magcustId" ElementName="Order_Info" ParameterXpath="//callReturn/cust_id" />
    </ActionParameters>
</Action>

Attributes for B1Query Actions

  • QueryName - The name of the query to execute inside the SAP Business One system via a call to the B1WebAPI. Results will be returned in standard B1WebAPI XML Format.
  • QueryCategory - The name of the B1WebAPI category that contains the query specified in the QueryName attribute. Defaults to B1WebAPI.

For example:

<Actions>
    <Action xsi:type="B1Query" RelatedInfoNode="MagentoDelivery" QueryName="MagentoDeliveryCheck" QueryCategory="Magento">
        <ActionParameters>
            <Parameter Name="b1document" WorkFlowMessageKey="true"/>
            <Parameter Name="TableName" Value="ODLN"/>
        </ActionParameters>
    </Action>
</Actions>

<Action type=”B1Object”>

This type of action is used to create a transactional object inside the SAP Business One system via XML from either a message or a previous action.

<Action xsi:type="B1Object" B1KeyXpath="some xpath" Method="insert"
   TransformXSLT="B1_CreateOrder.xslt" B1ObjectType="oOrders"
   CopyToFolder="SUCCESS" ExceptionFolder="FAILURE"
   RelatedInfoNode="OrderKey"/>

Attributes for B1Object Actions

  • B1KeyXpath - XPath to the b1 internal key that can be stored in a message.
  • Method - Insert/update.
  • B1ObjectType - Specifies the object type to create for the action.
  • HaltOnFail - [true|false] (optional) Boolean that specifies whether or not to keep processing upon failure.

For example:

<Actions>
    <Action xsi:type="B1Object" B1KeyXpath="something xpath" Method="insert" TransformXSLT="B1_CreateOrder.xslt" B1ObjectType="oOrders" CopyToFolder="SUCCESS" ExceptionFolder="FAILURE" RelatedInfoNode="OrderKey" />
    <Action xsi:type="B1Object" B1KeyXpath="something xpath" Method="insert" TransformXSLT="B1_CreateInvoice.xslt" B1ObjectType="oInvoices" CopyToFolder="SUCCESS" ExceptionFolder="FAILURE" RelatedInfoNode="InvoiceKey">
        <ActionParameters>
            <Parameter Name="OrderKey" ElementName="RelatedInformation" ParameterXpath="//OrderKey" />
        </ActionParameters>
    </Action>
    <Action xsi:type="B1Object" B1KeyXpath="something xpath" Method="insert" TransformXSLT="B1_CreatePayment.xslt" B1ObjectType="oIncomingPayments">
        <ActionParameters>
            <Parameter Name="InvoiceKey" ElementName="RelatedInformation" ParameterXpath="//InvoiceKey" />
        </ActionParameters>
    </Action>
</Actions>

<Action type=”PersistMessage”>

This type of action is used to store a message into the message queue table.

<Action xsi:type="PersistMessage" HaltOnFail="false" SuccessFolder="" ExceptionFolder="Failed" MessageType="SalesOrderImport" />

Attributes for PersistMessage Actions

  • SuccessFolder - Name of the message folder to use upon success when creating the new message in the queue. Leave this attribute empty if you only want messages created upon failure.
  • ExceptionFolder - Name of message folder to use upon failure when creating the new message in the queue.
  • MessageType - Type of the message to create in the system queue.

Custom Message Actions

The workflow framework supports the ability to write your own custom message actions to implement logic that is specific to your solution.

In order to complete the configuration of your custom message actions you will need to populate the CustomWorkFlowClass section of the workflow service B1WorkFlowService.config file. You will also have to make sure you custom dll is in the bin directory of the service. This is an example of how that was done for Magento:

<add key="B1WebAPI.WorkFlow.MagentoConnect.MagentoShipmentSender" value="Magento.WorkFlow.Connector.dll"></add>

In order to create a custom message action your class needs to implement one of the following classes. Each class has several methods that must be overridden, which can be identified in your code using Intellisense.

There are three options to inherit from when creating a custom action, as outlined below.

Custom Action Inheritable Classes
Class Description
B1Object

Use this class as your base class when you will be creating a B1 document. Ex: SPS Order Action.

If you plan on creating the objects directly via B1WebAPI or DIAPI then don't use this object.

Example code that can be executed via a custom action that inherits from B1Object:

result.B1ObjectKey = base.ProcessMessage(message, variables, workFlowBatchID, branchName);

BaseSender

Use this class as your base class when you require the full XML of a B1Object. If your message contains a b1object key and type base sender will auto load the object XML into your custom action. If you do not require the full object XML it is not required to use this class.

BaseAction

Use this class as your base class when the other two options are not applicable. This is the base action class that all workflow actions will use.

There are some base methods you will need to implement to use this class and you write your custom code in those methods.

Message XML Envelope

All Interconnect projects involve working with message XML generated by the SAP Business One system or the integrated external system. To improve the readability and consistency of our message XML a standard envelope will wrap the information that it contains. For more details, see XML Envelope Format for Interconnect.