Download as pdf or txt
Download as pdf or txt
You are on page 1of 173

Epicor Kinetic

BPM Cookbook
Classic
Disclaimer
This document is for informational purposes only and is subject to change without notice. This document and its
contents, including the viewpoints, dates and functional content expressed herein are believed to be accurate as of its
date of publication. However, Epicor Software Corporation makes no guarantee, representations or warranties with
regard to the enclosed information and specifically disclaims any applicable implied warranties, such as fitness for a
particular purpose, merchantability, satisfactory quality or reasonable skill and care. As each user of Epicor software is
likely to be unique in their requirements in the use of such software and their business processes, users of this document
are always advised to discuss the content of this document with their Epicor account manager. All information contained
herein is subject to change without notice and changes to this document since printing and other important information
about the software product are made or published in release notes, and you are urged to obtain the current release
notes for the software product. We welcome user comments and reserve the right to revise this publication and/or
make improvements or changes to the products or programs described in this publication at any time, without notice.
The usage of any Epicor software shall be pursuant to an Epicor end user license agreement and the performance of
any consulting services by Epicor personnel shall be pursuant to Epicor's standard services terms and conditions. Usage
of the solution(s) described in this document with other Epicor software or third party products may require the purchase
of licenses for such other products. Where any software is expressed to be compliant with local laws or requirements
in this document, such compliance is not a warranty and is based solely on Epicor's current understanding of such laws
and requirements. All laws and requirements are subject to varying interpretations as well as to change and accordingly
Epicor cannot guarantee that the software will be compliant and up to date with such changes. All statements of
platform and product compatibility in this document shall be considered individually in relation to the products referred
to in the relevant statement, i.e., where any Epicor software is stated to be compatible with one product and also
stated to be compatible with another product, it should not be interpreted that such Epicor software is compatible
with both of the products running at the same time on the same platform or environment. Additionally platform or
product compatibility may require the application of Epicor or third-party updates, patches and/or service packs and
Epicor has no responsibility for compatibility issues which may be caused by updates, patches and/or service packs
released by third parties after the date of publication of this document. Epicor® is a registered trademark and/or
trademark of Epicor Software Corporation in the United States, certain other countries and/or the EU. All other
trademarks mentioned are the property of their respective owners. Copyright © Epicor Software Corporation 2021.
All rights reserved. Not for distribution or republication. Information in this document is subject to Epicor license
agreement(s).

Classic
Revision: June 08, 2021 12:31 a.m.
Total pages: 173
sys.ditaval
BPM Cookbook Contents

Contents
Introduction............................................................................................................................5
Tips and Tricks of BPM Customization..................................................................................6
Put Customer on Credit Hold if Credit Review Date is Past Due.......................................14
Add Pre-Processing Directive to Put Order on Hold.........................................................................................15
Set Conditions........................................................................................................................................16
Evaluate Customer Credit Review Date...................................................................................................19
Set Hold, Notify, and Enable Post Processing...........................................................................................23
Review Workflow and Enable Directive...................................................................................................26
Test Directive..........................................................................................................................................27
Add Post-Processing Directive to Put Customer on Credit Hold.......................................................................29
Add Initial Workflow Elements................................................................................................................30
Try Invoking Customer.GetById Method..................................................................................................32
Add a Function.......................................................................................................................................34
Design Function Workflow......................................................................................................................36
Invoke Function......................................................................................................................................43
Test Directive..........................................................................................................................................46
Extend Post-Processing Logic to Put All Customer's Open Orders on Hold .....................................................46
Put All Open Orders on Hold...................................................................................................................46
Refresh Form Data and Reset BPM Logic.................................................................................................53
Test Directives................................................................................................................................................55
Automate Total Weight Calculation in Shipment Header.................................................58
Add a Pre-Processing Directive.......................................................................................................................58
Design Directive Workflow......................................................................................................................60
Add a Post-Processing Directive......................................................................................................................63
Link the Pre- and Post-Processing Directives............................................................................................64
Calculate Total Lines Weight...................................................................................................................65
Update Shipment Header........................................................................................................................70
Refresh Form Data..................................................................................................................................76
Review and Save Directive Workflow.......................................................................................................76
Test BPM Customization................................................................................................................................77
Set Up Optional Automation of Creating Resource for Employee...................................80
Add User-Defined (UD) Fields.........................................................................................................................81
Regenerate Data Model..........................................................................................................................83
Customize User Interface...............................................................................................................................84
Modify Employee Maintenance UI...........................................................................................................85
Modify Resource Group Maintenance UI.................................................................................................91
Add Pre-Processing Directive..........................................................................................................................94
Define Conditions for Executing Post-Processing Directive.......................................................................95
Add Function to Create New Resource and Resource Group..........................................................................99
Fill Tables for the New Resource Group and Resource and Invoke UpdateExt.........................................102

Epicor Kinetic | Classic 3


Contents BPM Cookbook

Handle Method Response.....................................................................................................................110


Add Post-Processing Logic............................................................................................................................114
Link to Pre-Processing and Invoke Function...........................................................................................115
Update Employee Record with Created Resource Data..........................................................................116
Refresh Data on Employee Maintenance Form......................................................................................121
Review the Workflow and Enable Directive...........................................................................................123
Test BPM Customization..............................................................................................................................124
Add New Misc Charge to Order Automatically................................................................130
Add a Pre-Processing Directive.....................................................................................................................130
Design Directive Workflow....................................................................................................................132
Add a Post-Processing Directive....................................................................................................................135
Check for Pre-Processing Condition......................................................................................................136
Get Order Number and Dataset............................................................................................................137
Create New Freight Misc Charge..........................................................................................................140
Update Sales Order and Refresh Data on the Form................................................................................147
Review and Save Directive.....................................................................................................................150
Test BPM Customization..............................................................................................................................151
Delete Multiple Part Records with Updatable BAQ.........................................................153
Add Query to Select Records for Deletion.....................................................................................................153
Design Query...............................................................................................................................................154
Add Base-Processing Method Directive.........................................................................................................158
Design Directive Workflow...........................................................................................................................159
Test Directive...............................................................................................................................................169

4 Epicor Kinetic | Classic


BPM Cookbook Introduction

Introduction

Each business is a unique mechanism. Business Process Management (BPM) is about individual tuning, automation,
and added efficiency. It can help tailor the standard and already versatile functionality of the Epicor ERP to the
exact needs of your business, however granular they may be.
Data transactions in the application are controlled by services. A service represents a type of data managed by
the application, such as a customer, part, or sales order. The services contain methods that perform a specific
task. Each service has methods that allow you creating new records, updating or deleting existing ones. For
example, you open Order Entry and bring up an order - the SalesOrder.GetByID method gets in action fetching
order data from the database to the client; you then change the Need By date and press Save - here's the
SalesOrder.MasterUpdate method feeding the DB with the new date. The Update method is probably the
most often used one - it's used for applying ANY changes you make in the user interface to the database.
BPM Cookbook is a collection of 'recipes' you can use to get a better hang of the BPM functionality built into
the Epicor ERP. The close-to-real-world examples (real-world actually, but sometimes intentionally simplified) are
specifically centered around what you can do with the Update/UpdateExt methods. It also provides some
general recommendations on using the available ERP tools to help you design efficient workflows.
The major BPM concepts covered in this cookbook include:
• Using Update and UpdateExt to create new records
• Using UpdateExt to modify multiple records at once
• Updating current and foreign records
• Updating user-defined (UD) fields
• Using Functions to deal with conflicting data tables
Each example has more specific concepts listed in their introductory section that also contains an overview of
the scenario's business value and implementation steps.
Go ahead and get started with some tips and tricks of BPM customization first.

Epicor Kinetic | Classic 5


Tips and Tricks of BPM Customization BPM Cookbook

Tips and Tricks of BPM Customization

This topic contains practical suggestions that can help you design better BPM workflows easier.

Use UI Trace to analyze the standard ERP logic you want to customize
Windows Forms

1. Turn on UI tracing - for example, like this:

2. Step through the procedure you wish to modify - for example, open a program, open a record, change
some fields, and save it.

3. Then analyze the log file.


The UI Trace will tell you exactly what service method is called and when. Depending on the tracing options
you select, it can also show you method parameters and related data changes - for example:

6 Epicor Kinetic | Classic


BPM Cookbook Tips and Tricks of BPM Customization

The UI trace was used to build every example in this guide.

Most often, custom logic is appended to an update service method. There could be different UI triggers for this
method, but you can be sure that every time you press Save on a from, some update method is executed. It can
be a direct Update - for example, EmpBasic.Update (Employee service), or it can be
MasterUpdate/UpdateMaster (wrapper methods for Update that perform some extra logic in complex UIs) -
for example, SalesOrder.MasterUpdate.
Note To find out more about setting up UI tracing, please go to the Logging > System Logs > Tracing
Options > Activate From Client topic in the System Administration Guide.

Kinetic Applications
Kinetic applications talk to the server via REST. To obtain details on called service methods, parameters, and
payload, you need to open an app in the browser, then inspect network activity in DevTools.
To display a Kinetic application in a browser:

1. First, launch the Home Page for your installation using the following URL format:
https://[ServerName]/[ERPInstance]/apps/erp/home/ - for example,
https://irv-euvm08.local/ERP102700/apps/erp/home/.

2. Search for and launch the application.


Alternately, if you know the app view ID, directly enter the application URL into the browser using the
following format:

Epicor Kinetic | Classic 7


Tips and Tricks of BPM Customization BPM Cookbook

https://[ServerName]/[ERPInstance]/apps/erp/home/#/view/[ViewID] - for example,


https://irv-euvm08.local/ERP102700/apps/erp/home/#/view/Erp.UI.SalesOrderEntry.
Note To be able to directly address an app, you must first go through the Home Page login.

3. Press F12 to bring up DevTools.

4. Go to the Network tab and review the information on the REST calls from the client.

5. Select a name to view call details - for example:

8 Epicor Kinetic | Classic


BPM Cookbook Tips and Tricks of BPM Customization

Use Field Help to get details on the database fields involved in transactions
Windows Forms
To launch Field Help in the client, in any program, in the Main Menu, go to Help > Field Help. The Field Help
slides out. You can dock it and adjust its position on the screen as you like. Then select a program field to view
its properties - for example:

Epicor Kinetic | Classic 9


Tips and Tricks of BPM Customization BPM Cookbook

The help for each field contains two tabs:


• Field Level Help (default view) - contains the field description.
• Technical Details - contains details on database binding, format, data type, like field (if any). etc.
This information can help you identify the exact table(s) and field(s) that your custom workflow will be
interacting with.

Kinetic Applications
For the description of a specific field on a Kinetic Application screen, use the program's Application Help. You
can check out the field's Ep Binding property in the Application Studio. To do this:

1. Launch the Application Studio by selecting Customization from the Overflow menu in the top right corner
of the application screen.

2. In the Application Studio, choose the page that contains your field and open its layout.

3. Select a control on the layout and view its properties - for example:

10 Epicor Kinetic | Classic


BPM Cookbook Tips and Tricks of BPM Customization

Use the Data Dictionary Viewer program for complete technical information on database fields.

Use Data Dictionary Viewer for more detail on tables and fields
Menu Path: System Setup > System Maintenance > Data Dictionary Viewer.
You can use this program to find out more information on database fields. For example, you can see some
properties of the database fields tied to Kinetic UI controls like Format, Data Type, Like field, etc. that otherwise
you wouldn't be able to see anywhere else.
For each database table, the Data Dictionary Viewer also provides the list of the existing indexes. This is the only
place in the system where these indexes can be viewed in the system, which is especially relevant for the Epicor
Cloud ERP where users do not have direct access to the database. Indexes can help you design more efficient
table joins and filters in your Business Activity and BPM Queries to ensure optimal performance. Each index has
an ordered list of included table columns. To make your database query more efficient, make sure you use those
fields in either a join or where clause.

Use Epicor Functions to isolate portions of BPM workflow


Epicor Functions are self-contained units of business logic that can be reused in multiple BPM workflows. Use
them to avoid duplication and to make logic updates easier.
Epicor Functions define their own context. This allows preventing conflicts of identical tableset types. Some
tableset types are defined in more than one service - for example, both in Customer and Sales Order or Employee
and Resource. If you have these services in the same workflow, the system will fail to compile the BPM directive.
Isolating the logic pertaining to a specific service using a Function eliminates this conflict.

Use RowMod to better identify records during transaction


There are three row states that you can define for dataset records. These states are temporary and last for the
duration of the transaction only. You can define records as Added (A), Changed (U), or Deleted (D).
There are two ways to define them in expression editor:
• "A" / "U" / "D", or
• IceRow.ROWSTATE_ADDED / IceRow.ROWSTATE_UPDATED / IceRow.ROWSTATE_DELETED

Epicor Kinetic | Classic 11


Tips and Tricks of BPM Customization BPM Cookbook

Use Information Messages to debug code/datasets


Sometimes things go wrong and you don't even know where exactly. Using Information Messages in your
workflow often helps to quickly solve the mystery. Use the insert functionality to display current dataset values
at different stages of the workflow to identify what part of your logic fails to execute.

Define Service Method before changing its dataset


As a rule, prior to calling a method, you modify its input dataset. You can use a variety of BPM Setter actions like
Fill/Update Table by Query or Set Field to add new or change/delete existing records in a dataset. You do
this in the in-memory copy of the method dataset that is stored in a directive-level variable of the tableset type.
If you first set up method parameters in the Invoke BO Method action, you can simply create a new variable
and bind it to the ds parameter of tableset type pre-defined for this method. For example, you want to update
a Customer Shipment record using CustShip.UpdateExt. The method's ds parameter has a pre-defined data
type - UpdExtCustShipTableset. In the Binding field, select create new variable and just add a name for it.
Now, use an appropriate setter action to specify data that will be mapped to a table from the
UpdExtCustShipTableset.
Creating a variable for the method dataset first requires that you know the exact name of the tableset used by
the method.

Create/Update foreign records in post-processing


While, as a rule, you update current records in pre-processing, you update foreign records in post-processing.
This prevents creating new or updating existing records if, for some reason, the current record fails to update.
Updating foreign records in pre-processing can result in a situation when you have record(s) that shouldn't be
there because the pre-condition (current record update) was not complete.
In one of the examples in this guide, you will create a new Resource record (foreign) when you update a UD field
on an Employee (current). Imagine something prevents you from updating the current Employee record. Had the
logic for creating a new Resource been in pre-processing, you would already end up with a yet unwanted Resource.

In post-processing, invoke GetById to refresh data in the current UI after update


In post processing, when the update is complete, the database has new data but what you see on the screen is
still what has been fetched from DB before the update. If an end-user does not know that they need to manually
refresh the UI, they can think that the update didn't go through. Calling a GetById method at the end of the
update logic automatically does this refresh.
For example, you changed some field on a sales order record. This automatically updates another field of the
same record in the database. If the BPM workflow contains a GetById method call, you will immediately see the
updated field value on the form.

Use Epicor University resources on BPM/Functions


Besides this guide, use the following education and documentation resources to lean more about working with
BPM and Epicor Functions:
• Business Process Management courses in the Epicor Learning Center:
Course Catalog > Browse > Tools and Administration > Business Process Management.
• Embedded Education courses:
• Business Process Management
• Advanced Business Process Management
• Introduction to Epicor Functions
• Advanced Epicor Functions.

12 Epicor Kinetic | Classic


BPM Cookbook Tips and Tricks of BPM Customization

• Business Process Management section of the Tools User Guide - also includes some hands-on examples
of customizing different types of services
• Business Process Management documentation in Application Help - System Management > Business
Process Management

Epicor Kinetic | Classic 13


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

Put Customer on Credit Hold if Credit Review Date is Past


Due

In this example, you will create custom logic to automatically put a customer on credit hold and all their open
orders on hold if the customer's credit review date is before the sales order date.
Whenever you create a new or update existing sales order, this logic will check the Credit Review Date in the
customer record. If it is before the Order Date, when you save the order, the system puts the current order on
hold and issues a notification (in this example, it's an info message, but it can be an email to a financial controller,
for example). It then puts the customer on Credit Hold as well. Finally, all open orders of that customer are put
on hold to prevent their further processing.
BPM Concepts Covered in the Example:
• Updating the current record in a Pre-Processing Directive
• Updating a foreign record in a Post-Process Directive
• Using UpdateExt to modify multiple records at once
• Using Functions to deal with conflicting data tables
You will first add a pre-processing directive for the SalesOrder.MasterUpdate method that will:
• Set a condition to trigger a credit review date check only when you create a new or update existing sales
order.
• Set another condition to prevent a cyclic loop.
The workflow you are about to develop consists of multiple stages. At one stage, after the system updates
the customer record (puts on credit hold), it then updates all open orders of that customer (if any), which
triggers the pre-processing directive again creating a cyclic loop. This condition will prevent this by evaluating
a BPM Data Field "marker".
• Get the current Order Date and compare it with the customer's Credit Review Date. Further logic executes
only if the Order Date is greater than the Credit Review Date.
• If the Order Date is later than the Credit Review Date, set the OrderHeld field of the OrderHed table to True.
• Display an info message explaining why the order is put on hold.
• Enable post-processing logic.
The post-processing directive will do the following:
• Run only if the pre-processing logic has executed.
• Set the value of the ShortChar05 BPM Data field to Done (it can actually be any string). This way, when
subsequent logic finds open customer orders and invokes SalesOrder.MasterUpdate to put them on hold,
the pre-processing won't start again because the context BPM field is not empty.
• Invoke a Function that will do the customer record update (put customer on credit hold).
• Get the current order number to exclude it from the subsequent query that will select and update all customer
open orders.
• Use the Fill Table by Query action to create a temporary dataset (dsSOUpdateExt) with all the customer's
open order records, except the one that has been previously updated (put on hold).
• Invoke the SalesOrder.UpdateExt method using the temporary dsSOUpdateExt dataset.
• Call the GetById method to refresh the current order data on the Order Entry form.
• Finally, set the BPM Field value to Empty again to reset the directives.

14 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

Add Pre-Processing Directive to Put Order on Hold

In this sub-step, create a pre-processing directive for the SalesOrder.MasterUpdate method.

1. Open the Method Directives program.


Menu Path: System Management > Business Process Management > Method Directives Maintenance.

2. On the Detail sheet, click the Method Code button.


The Method Search window displays.

3. Verify the System Code is set to ERP and the Type is set to Business Object, then in the Service Name
field, type in salesorder.

4. In the Where Method Name Starts At field, enter master.

5. Click Search.

6. Select MasterUpdate in the Search Results and click OK.

7. From the New drop-down in the Toolbar, select New Pre-Processing.

Epicor Kinetic | Classic 15


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

The Pre-Processing > Detail sheet opens for editing.

8. For Directive Name, type in Check Credit Review Date.

9. Enter a Description - for example, Puts order on hold if customer credit review date is before order
date.

10. In the Group feild, type in CreditCheck.

11. Save the directive and move on to the next step to design directive workflow.

Set Conditions

In this step, define the conditions for triggering custom logic.


First of all, you will make sure that your custom logic is triggered only when an order is created or updated. The
logic will not fire if the SalesOrder.MasterUpdate method dataset does not contain any updates to the OrderHed
table.
In this example, you need to use another condition to avoid cycled BPM execution. The custom post-processing
logic you are about to design will update the order header which satisfies the previous condition and triggers
the post-processing logic again thus creating a cyclic loop. In this additional condition, we will evaluate the value
of a selected callContextBpmData table field (any empty field). In post-processing you will assign a value to
this field, and the post-processing logic will not run again unless that value is empty.

16 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

1. On the Pre-Processing > Detail sheet with your new directive, click Design.

The BPM Workflow Designer launches.

2. From the Flow Chart pane on the left, select the Condition widget and add it to the workflow.

3. Connect the Start widget with the Condition 0 widget.

4. Select the Condition 0 widget, then in the Properties > Condition 0 sheet, click the New icon.
A new condition line is added.

a. From the drop-down in the Condition column, select the following statement:
There is at least one updated row in the specified table.

b. In the updated drop-down, select added.

Epicor Kinetic | Classic 17


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

c. Click the specified link.


The Select Table window displays.

d. Verify ds.OrderHed displays in the Table field and click OK.

5. On the Properties > Condition 0 sheet, click the New icon again.
A new condition line with an And Operator is added.

a. Change the Operator to Or.

b. From the drop-down in the Condition column, select the following statement:
There is at least one updated row in the specified table.

c. Click the specified link.


The Select Table window displays.

d. Verify ds.OrderHed displays in the Table field and click OK.

6. Combine the first two statements by adding an opening bracket into the Prefix column of the first condition
line and a closing bracket into the Postfix column of the second condition line.

7. On the Properties > Condition 0 sheet, click the New icon one more time.
A new condition line with an And Operator is added.

a. Keep the And operator.

b. From the drop-down in the Condition column, select the following statement:
The specified call context field is equal to the specified expression.

c. Click the specified call context link.

18 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

The Select Table Field(s) window displays.

d. From the callContextBpmData table, select the ShortChar05 field and click OK.

e. Keep the is equal to link unchanged.

f. Now click the specified link.


The Specify C# expression window displays.

g. Add the folloing expression to the Editor:


String.Empty

h. Select OK to close the window.

Evaluate Customer Credit Review Date

In this sub-step, check if the current Order Date is greater than the customer Credit Review Date.
You will first extract the Order Date from the OrderHed table. You will need this date to compare it against
the Credit Review Date in the Customer record.
Then, you will add another condition that will evaluate the customer Credit Review Date against the Order
Date. The workflow will continue only if the Order Date is greater than the Credit Review Date.

1. In the BPM Workflow Designer, navigate to the Properties > Variables sheet and click New.

Epicor Kinetic | Classic 19


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

A new line appears in the Variables grid.

2. Add a new directive-level variable that will store current order number:

Name Type
orderDate DateTime

3. From the Setters pane, select the Set Argument/Variable widget and drag it onto the canvas.
Rename it to GetOrderDate.

4. Connect the true end of the Condition 0 widget to GetOrderDate.

5. Select the Set Argument/Variable widget in the workflow and configure it as follows:

a. On the Properties > Actions sheet, select the first specified link in the action statement.
The Select an Argument/Variable window displays.

b. Select the orderDate variable at the end of the list and click OK.

c. Click the second specified link.


The Specify C# expression window displays.

20 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

d. On the Available Variables panel, expand the ds node and then OrderHed. Select the OrderDate
field and double-click on it..
The following expression appears in the Editor: dsOrderHedRow.OrderDate

Note If you are confident about syntax and spelling of a specific field name, you can manually
enter this expression directly into the Editor. Use the Check Syntax button to validate your
expression.

e. Click OK.

6. Next, add another condition to the workflow.

Epicor Kinetic | Classic 21


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

Connect GetOrderDate to Condition 1.

7. Select Condition 1 and configure it like this:

a. From the drop-down in the Condition column, select the following statement:
Number of rows in the designed query is more or equal to 1.
You will use a query to select the current customer specified in the order from the Customer database
table and make sure their Credit Review Date is smaller than the Order Date.

b. Click the designed link.


The Compose Query window displays.

22 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

c. From the Tree View on the right, select the Erp.Customer table and drag it onto the canvas.

d. Make sure the ERP.Customer table widget is selected and navigate to Table Criteria.

e. Add criteria per the table below:

And/Or ( Not Field Operation Field Value )


Company = BAQ CompanyID constant
And CustNum = @iCustNum argument/variable
And CreditReviewDate < @orderDate argument/variable

Here you set the Customer.Company field equal to the current Company ID, Customer.CustNum
equal to the value of the CustNum argument of the MasterUpdate method, and finally,
CreditReviewDate smaller than the date you store in the orderDate variable (the current order date).

f. In the Compose Query program, click OK.

g. Keep all other condition statement variables intact.

Set Hold, Notify, and Enable Post Processing

1. From the Setters pane, select the Set Field widget and add it to the workflow.
Rename it to PutOrderOnHold.

Epicor Kinetic | Classic 23


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

2. Connect the True end of the Condition 1 widget to PutOrderOnHold.

3. Select the PutOrderOnHold widget and configure the action:

a. Click the first specified link.

b. On the Select Table Field(s) window, choose the OrderHeld field and click OK.

c. Do not change the value of the second link.

d. Click the second specified link.


The Specify C# expression windows pops up.

24 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

e. In the Editor, type in true and click OK.

4. From the Other pane, select the Show Message widget and drag it onto the canvas.
Connect the PutOrderOnHold widget to Show Message.

5. Click the designed link.


The Design Information Message Template window displays.

6. Replace the default message text with this:

Epicor Kinetic | Classic 25


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

The customer's credit review date is before the order date, the order has automatically been put
on hold.

7. Click OK.

8. From the Other pane, select the Enable Post Directive widget and drag it onto the canvas.
Connect Show Message to Enable Post Directive.

Review Workflow and Enable Directive

In this sub-step, review your workflow and enable the directive.

1. Verify your workflow contains all the elements per the below image:

26 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

2. Save the workflow and close the BPM Designer.

3. In the Method Directives Maintenance program, enable and save the directive.

Test Directive

In this sub-step, test the logic you've created so far in pre-processing stage of the method execution.

1. Launch Customer Maintenance.


Menu Path: Sales Management > Order Management > Setup > Customer.

Epicor Kinetic | Classic 27


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

2. In the Customer field, type in Addison and press Tab.


Details for Addison display on the form.

3. Navigate to the Billing > Credit > Credit Detail sheet and make sure the Review Date is in the past
compared to your current date.

4. Keep Customer Maintenance open and launch Order Entry.


Menu Path: Sales Management > Order Management > General Operations > Order Entry.

5. Create a new order for Addison.

6. Save the empty order.


Note the message:.

28 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

The order has been put on hold:

Add Post-Processing Directive to Put Customer on Credit Hold

In this step, add logic that will put the customer on Credit Hold if at the time of creating an order, the customer
Credit Review Date is before the Order Date.

1. In the Main toolbar of the Method Directives program, select New > New Post-Processing.

Epicor Kinetic | Classic 29


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

The Post-Processing > Detail sheet displays.

2. For the Directive Name, type in:


Set Customer Credit Hold / Orders Hold.

3. Enter a Description - for example:


Puts the customer on Credit Hold if the Credit Review Date is before Order Date. Puts all open
orders of this customer on hold.

4. In the Group field, select the CheckCredit.

5. Click Design.
The BPM Workflow Designer displays.

Move on to the next sub-step to design the directive workflow.

Add Initial Workflow Elements

In this sub-step, you will link this post-processing directive to the pre-processing one you created previously. In
the very beginning of the workflow, you will also set a value for the callConextBpmData.ShortChar05 field to
prevent a cyclic loop.

1. From the Flow Chart pane, select the Condition widget and add it to the canvas.
Connect the Start widget to the Condition 0 widget.

30 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

2. Navigate to the Properties > Condition 0 sheet and click New.


A new condition line appears in the grid.

3. Select the following statement:


This directive has been enabled from the specified directive.

a. Click the specified link.


The Select a primary directive to depend on window displays.

b. Verify the Pre radio button is selected and choose Check Credit Review Date from the Directive
drop-down.

c. Click OK.

4. Now, from the Setters pane, select the Set BPM Data Field widget and drag it onto the canvas.

Epicor Kinetic | Classic 31


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

5. Connect the True end of Condition 0 to the Set BPM Data Field widget.
Configure the action:

a. Click the first specified link.


The Select Table Field(s) window appears.

b. Select the ShortChar05 field of the callContextBpmData table and click OK.

c. Click the second specified link.

d. In the Specify C# expression window, type in a string value - for example "Done" into the Editor and
click OK.

Try Invoking Customer.GetById Method

In this sub-step, let us try calling the Customer.GetById method from our BPM workflow.
In this example, we will intentionally bump into a common obstacle when combining different Epicor services -
that is of matching tableset types in more than one services. Complex business objects contain numerous tablesets.
When you have two or more of such business objects, like Customer and Sales Order, in a BPM workflow, chances
are you may have the same tableset type(s) in more than one of these services, which will cause compilation
error(s).
Epicor Function is isolated business logic with its own context. In the next sub-step, you will pack the BPM logic
for setting Credit Credit Hold into a Function. This will eliminate the "matching tablesets" framework issue.

1. From the Callers pane, select the Invoke BO Method widget and add it to the workflow.
Connect Set BPM Data Field to Invoke BO Method.

32 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

2. Select the Invoke BO Method widget and configure it:

a. Click the first specified link.


The Method Search window displays.

b. Select the GetById method of the Customer service and click OK.

c. Click the not configured link.


The Setup Method Parameters window pops up.

d. For the custNum parameter, select the iCustNum parameter of the SalesOrder.MasterUpdate method.

e. For <return value>, add a local variable - for example, dsCustomer.

f. Click OK.

3. Save the workflow and close the Designer.

4. Enable and save the directive.

Epicor Kinetic | Classic 33


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

The Server Side Error message displays. The directive failed to compile because of identical tablesets in
the Customer and Sales Order services.

Do not close Method Directives and proceed to the next sub-step to create a Function.

Add a Function

In this sub-step create a Function to set customer on credit hold.

1. Launch Epicor Functions Maintenance.


Menu Path: System Management > Business Process Management > Epicor Functions Maintenance.
Note Your user account must be assigned to the Functions Administrator and Functions Developer
Security Groups.

2. Select New > Add Library.


The Summary sheet displays for editing.

3. In the Library field, type in CustomerCredit and press Tab.

34 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

4. Now go to the References > Services sheet and click Add.


The Service Search window displays.

5. Select the Erp.BO.Customer service and click OK.

6. Next, move on to the Security sheet.

7. Add Epicor Education to the Authorized Companies list.

8. From the New drop-down in the Main toolbar, select Add Widget Function.

The Function sheet displays.

Epicor Kinetic | Classic 35


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

9. For the Function ID, type in SetCustCreditHold.

10. Add a Description - for example: Sets customer to be on Credit Hold.

11. On the Function > Signature sheet, add one input parameter:

Name Type
custNum System.Int32

Note Customer Number (Customer.CustNum) is the required input parameter for the
Customer.GetById method that we are going to call in the Function.

12. On the Function > Signature sheet, click Complete.

13. Save the library and Function.

Keep the Function open and move on to the next sub-step.

Design Function Workflow

In this sub-step, design the Function workflow to set Credit Hold and update the Customer.

1. From the Callers pane, select the Invoke BO Method widget and add it to the workflow.
Connect the Start widget to the Invoke BO Method widget.

36 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

2. Rename the newly added widget to Customer.GetById.


Configure the action as follows:

a. Click the first specified link.


The Method Search window displays.

b. Select the GetById method of the Customer service and click OK.

c. Click the not configured link.


The Setup Method Parameters window pops up.

d. For the custNum method parameter, select the Function's custNum input parameter.

e. For <return value>, add a local variable - dsCustomer.

f. Click OK.

You will get the Customer dataset and store it in a local variable.

3. From the Setters pane, select the Update Table by Query widget and drag it onto the canvas.
Rename it to SetCreditHold.

Epicor Kinetic | Classic 37


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

4. Connect Customer.GetById to SetCreditHold.

5. Select the SetCreditHold widget and configure its action:

a. Click the designed link.


The Compose Query window displays.

38 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

b. From the table list on the left, select the dsCustomer.Customer table.

c. Navigate to the Display Fields sheet and select at least one field to display - for example, Company.

Note This is required by the system to run the query. You are updating the local dataset and
therefore do not need any Display Fields but the one required.

d. Click OK.

e. Keep the all rows action statement parameter.

f. Click the first specified link.

g. On the Select Table window that pops up, verify the dsCustomer.Customer table is displayed and
click OK.

h. Click the second specified link.


The Setup Table Mapping window displays.

Epicor Kinetic | Classic 39


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

i. Click Bind Automatically.


The Company column has been automatically bound to the Company display field.

j. Bind the CreditHold and RowMod columns to the below expressions:

Name Binding Explanation


CreditHold expr: true This will set the Credit Hold check box in the customer record.
RowMod expr: "U" This will mark the row as updated in database.

k. Click OK.

6. Finally, add another Invoke BO Method widget to the workflow.


Rename it to UpdateCustomer.

40 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

7. Connect the SetCreditHold widget to the UpdateCustomer widget.

8. Select the UpdateCustomer widget and configure it like this:

a. Click the first specified link.


The Method Search window displays.

Epicor Kinetic | Classic 41


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

b. Select the Update method of the Customer service and click OK.

c. Click the not configured link.


The Setup Method Parameters window pops up.

d. For the ds in-out parameter, select the local dsCustomer variable.

e. Click OK.

9. Review and Save the workflow and close the Function Designer.

42 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

10. Promote the CustomerCredit library to production.

Invoke Function

In this sub-step, invoke the SetCustCreditHold Function from the BPM workflow.

1. Open your post-processing directive workflow in the BPM Workflow Designer.

2. From the Callers pane, select Invoke Function and drag it onto the canvas.
Connect the Set BPM Data Field widget to the Invoke Function widget.

Epicor Kinetic | Classic 43


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

3. Select the Invoke Function widget and set it up as follows:

a. Keep the Synchronously parameter as is.

b. Click the library link.


The Library Search window displays.

c. Select the CustomerCredit library and click OK.

d. Click the function link.

e. On the Function Search window, select the SetCustCreditHold Function and click OK.

f. Finally, click the not configured link.


The Setup Function Parameters window displays.

44 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

g. Bind the custNum Function parameter to the iCustNum variable and click OK.

4. Delete the previously created dsCustomer variable to avoid the compilation error.

5. Review and Save the workflow and close the BPM Designer.

Keep the BPM Workflow Designer open and proceed to the next set of steps.

Epicor Kinetic | Classic 45


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

Test Directive

In this sub-step, run a quick test to see how the designed logic works now.

1. Create another order for Addison in the Sales Order Entry program.

2. Save the empty order.


Note the info message saying the order is put on hold.

3. Now, open Customer Maintenance and bring up Addison's record.


Note the Credit Hold check box on the Billing > Credit > Credit Detail sheet is now selected. The customer
has been put on Credit Hold:

Extend Post-Processing Logic to Put All Customer's Open Orders on Hold

In this step, add a few more widgets to the Post-Processing Directive workflow to set all open orders of a specific
customer on hold when this customer is put on Credit Hold.

Put All Open Orders on Hold

In this sub-step, add logic that will select all open orders of the current customer and put them on hold.

1. On the Properties > Variables sheet, declare a new variables per the table below:

Name Type Explanation


localOrderNum Integer This variable will store the current order number so that it
could be included from the query that selects open orders.
dsSOUpdateExt UpdExtSalesOrderTableset This variable will store the updates you make to the open
order records. This dataset will be used by the
SalesOrder.UpdateExt method to update multiple order
records in the database.

To add the dsSOUpdateExt variable of tableset type:

46 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

a. From the drop-down in the Type column, select Choose type.


The Select variable type window displays the available assemblies.

b. Locate and expand the Erp.Contracts.BO.SalesOrder node.

c. Select Erp.Tablesets.UpdExtSalesOrderTableset and click OK.

Epicor Kinetic | Classic 47


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

2. From the Setters pane, select the Set Argument/Variable widget and add it to the workflow.
Connect the Invoke Function widget to the Set Argument/Variable widget.

3. Change the Action Name to GetOrderNum and configure it like this:

a. In the Action statement, select the first specified link.

b. In the Select an Argument/Variable window, choose localOrderNum and click OK.

c. Click the second specified link.


The Specify C# expression window displays.

d. In the Editor, type in dsOrderHedRow.OrderNum and click OK.

4. Again form the Setters pane, select the Fill Table by Query widget and drag it onto the canvas.
Rename the widget to SelectOpenOrders.

48 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

5. Connect GetOrderNum to SelectOpenOrders.

6. Configure the SelectOpenOrders widget:

a. Click the designed link to launch the Compose Query program.

b. On the Phrase Build sheet of the Compose Query window, select the Erp.OrderHed table from the
list and add it to the canvas.

c.

Select another table - Erp.Customer - and add it to the canvas too.


Note that when you add the second table the relation between the two tables is set up automatically.
Keep the default table relation.

d. Select the ERP.OrderHed table on the canvas and add the following Table Criteria:

Epicor Kinetic | Classic 49


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

And/Or ( Not Field Operation Filter Value )


CustNum = @iCustNum argument/variable
And OrderNum <> @localOrderNum argument/variable
And OrderDate > Customer.CreditReviewDate table field value
And OpenOrder = true constant

By using these criteria, you select all open orders for the customer with Order Date later than the customer
Credit Review Date.

e. Navigate to the Display Fields sheet and add a couple of fields to display. You must have at least one.
In this example, select the twp key fields of the OrderHed table - OrderNum and Company - and click
OK.

f. Click the specified link.

g. In the Select Table window, choose the dsSOUpdateExt.OrderHed table and click OK.

50 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

h. Click the not configured link.


The Setup Table Mapping window displays.

i. Click Bind Automatically.


Two bindings for the OrderNum and Company fields are created automatically.

j. Locate the OrderHeld field and bind it to the true expression.

k. In Setup Table Mapping, click OK.

7. Add an Invoke BO Method widget to the workflow.


Rename it to SO.UpdateExt.

8. Connect SelectOpenOrders to SO.UpdateExt.

Epicor Kinetic | Classic 51


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

9. Configure the SO.UpdateExt widget:

a. Click the specified link.

b. In the Method Search window, select the Erp.BO.SalesOrder.UpdateExt method.

c. Click the not configured link.


The Setup Method Parameters window displays.

d. Bind the ds in-out method parameter to the local dsSOUpdateExt variable.

e. Bind the continueProcessingOnError parameter to the true expression, and the


rollbackParentOnChildError parameter to the false expression.

f. Ignore all other parameter as irrelevant and click OK.

Keep the workflow open and move on to the next sub-step.

52 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

Refresh Form Data and Reset BPM Logic

In this sub-step, call the GetById method of the Sales Order BO to refresh data on the Order Entry form and set
the BPM Field value to empty again as BPM Call Context fields will persist into the User Interface. Therefore, the
flag needs to be cleared in order to allow the BPM logic to be triggered on another order.

1. From the Callers pane, select the Invoke BO Method widget and add it to the canvas.
Rename it to SO.GetById.

2. Connect SO.UpdateExt to SO.GetById.

3. Configure the SO.GetBuId widget like this:

a. Click the specified link and select the Erp.BO.SalesOrder.GetById method in the Method Search
program.

b. Click the not configured link.


In the Setup Method Parameters window, link the orderNum parameter to the localOrderNum
variable, and <return value> to the default ds variable.

c. Click OK.

Epicor Kinetic | Classic 53


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

4. From the Setters pane, select the Set BPM Data Field widget and drag it onto the canvas.
Connect the SO.GetById widget to the Set BPM Data Field widget.

5. Configure the Set BPM Data Field widget:

a. Click the first specified link.


The Select Table Field(s) window displays.

b. From the callContextBpmData table, select the ShortChar05 field and click OK.

c. Now click the second specified link.


The Specify C# expression window displays.

d. Add the folloing expression to the Editor:


String.Empty

e. Select OK to close the window.

6. Review and Save the workflow, then close the BPM Workflow Designer.

54 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

7. Back on the Method Directives window, enable and save the directive.

You can now test your custom logic.

Test Directives

In this sub-step, test the whole customization.


Create a new order for Addison again and verify the order is put on hold and customer is put on Credit Hold if
their Credit Review Date is before the order date. Then verify all open orders for Addison are put on hold as well.
Note In this example, the Kinetic Order Entry is demonstrated.

1. Launch Order Entry and create a new empty order for Addison.

2. Save the order.

Epicor Kinetic | Classic 55


Put Customer on Credit Hold if Credit Review Date is Past Due BPM Cookbook

Note the message saying the order has been put on hold. Verify the order has been put on hold.

3. In the Sales Order Entry program (Kinetic UI), click the Sales Orders navigation link in the top left corner
of the screen to return to the Order Entry application landing page.

4. From the Overflow Menu, select Search.

The Search panel slides out.

5. In the Bill To Customer field, type in addison and press Tab.

6. Click Search.
The search results display.
Note that all open orders for Addison with date later than the customer Credit Review Date are now put
on hold. Closed orders have not been affected.

56 Epicor Kinetic | Classic


BPM Cookbook Put Customer on Credit Hold if Credit Review Date is Past Due

7. If Addison's open orders have been put on hold, this automatically means the customer has been put on
Credit Hold. However, you may as well verify that by opening Addison's record in the Customer Maintenance
program. The Credit Hold check box on the Billing > Credit > Credit Detail sheet should be selected.

Epicor Kinetic | Classic 57


Automate Total Weight Calculation in Shipment Header BPM Cookbook

Automate Total Weight Calculation in Shipment Header

In this example, implement a scenario to display the total weight of all lines in a shipment in the shipment header.
You will customize the logic of the UpdateMaster method of the Customer Shipment (CustShip) service to
automatically update the shipment weight in the Header when a certain condition is satisfied.
BPM Concepts Covered in This Example:
• Updating the current record with data taken directly from the database
• Using custom logic for calculating a value to update
You will first create a pre-processing directive that will evaluate the defined conditions for triggering the updating
of the Weight field in the Header. The update will execute whenever:
• a new line is added to the shipment pack
• the line weight is changed
• the Unit of Measure (UOM) in the shipment Header is changed
Note The main purpose of this exercise is to demonstrate the use of the Fill Table by Query BPM
action in combination with calling a service BO UpdateExt method. Therefore, the weight calculation
logic has been simplified to cater for just the three basic UOMs - grams (g), kilograms (kg), and pounds
(lb). Furthermore, the calculation logic will not go into complicated UOM conversion, and if there are
lines with varying UOMs, it will take into account only the lines with the UOM matching the UOM
defined in the Header, and recalculate the weight if the Header UOM is changed.

You will then create a post-processing directive and link it to the pre-processing one. The post-processing directive
will implement the following logic:
• First of all, it will get the weight data for all the lines in the current pack with the UOM matching the Header
UOM directly from the ShipDtl database table. The obtained data will be stored in the directive-level variable
of Tableset type.
• It will then perform the weight calculation. The result will be assigned to a simple decimal directive-level
variable.
• Next, it will get the full Customer Shipment service tableset from the database and change it by replacing the
weight value with the result of the directive calculation.
• Finally, it will call the UpdateExt method of the Customer Shipment service to update the pack weight value
in the database.
• Additionally, it will call the GetByID method of the Customer Shipment service to update weight data on the
Customer Shipment Entry form.

Add a Pre-Processing Directive

In this step, add a pre-processing directive to set conditions for execution of the post-processing directive.

1. Launch Method Directives Maintenance.


Menu Path: System Management > Business Process Management > Method Directives Maintenance.

2. On the Detail sheet, click the Method Code button.

58 Epicor Kinetic | Classic


BPM Cookbook Automate Total Weight Calculation in Shipment Header

The Method Search window displays.

3. On the Basic sheet, for Service Name, type in CustShip, and in the Where Method Name Starts At
field, enter updatemaster.

4. Click Search.

5. Select the UpdateMaster method of the CustShip business object and click OK.

6. In the Toolbar, from the New drop-down, select New Pre-Processing.

The Pre-Processing sheet displays on the form.

Epicor Kinetic | Classic 59


Automate Total Weight Calculation in Shipment Header BPM Cookbook

7. For Directive Name, enter AutomaticWeight.

8. Add a Description - for example, Defines conditions for the AutomaticWeight post-processing
directive.

9. In the Group field, type in AutomaticWeight.

10. Keep the default Company Scope.

11. Save the directive.

Move on to the next step to design this directive's workflow.

Design Directive Workflow

In this sub-step, define the condition that will trigger the post-processing directive.

1. On the Pre-Processing sheet with your directive details, click Design.


The BPM Workflow Designer window displays.

2. From the Flow Chart pane on the left, select the Condition widget and drag it onto the canvas.
Connect the Start widget to the Condition.

60 Epicor Kinetic | Classic


BPM Cookbook Automate Total Weight Calculation in Shipment Header

3. Select the Condition widget and on the Properties > Condition sheet below the canvas, click the New
icon.
A new condition line is added.

4. From the drop-down in the Condition column, select The specified field has been changed from any
to another statement.
Define its variables as follows:

a. Click the specified link.


The Select Table Field(s) window displays.

b. In the Table field, select ds.ShipDtl.

c. Then select the TotalNetWeight field and click OK.

5. On the Properties > Condition sheet, click New again.


The second condition line is added.

6. Change the Operator to Or, then from the Condition drop-down, select the following statement: There
is at least one updated row in the specified table.
Configure the statement like this:

a. From the updated drop-down, select added.

b. Click the specified link.

Epicor Kinetic | Classic 61


Automate Total Weight Calculation in Shipment Header BPM Cookbook

The Select Table window displays.

c. In the Table field, select ds.ShipDtl and click OK.

7. Add the third condition and change the Operator to Or again.

8. From the drop-down in the Condition column, select The specified field has been changed from any
to another statement.
Configure the condition as follows:

a. Click the specified link.


The Select Table Field(s) window displays.

b. In the Table field, select ds.ShipHead.

c. Then select the WeightUOM field and click OK.

9. From the Other pane, select the Enable Post Directive widget and add it to the workflow.
Connect the True end of the Condition widget to Enable Post Directive.

10. Save the workflow.

11. Close the BPM Workflow Designer.

12. Enable and save the AutomaticWeight pre-processing directive.

62 Epicor Kinetic | Classic


BPM Cookbook Automate Total Weight Calculation in Shipment Header

Keep the Method Directives Maintenance open and move on to creating the post-processing directive.

Add a Post-Processing Directive

In this step, create a post-processing directive that will use data from database to update total shipment weight.

1. In Method Directives Maintenance, from the New drop-down, select New Post-Processing.

The Post-Processing sheet displays.

Epicor Kinetic | Classic 63


Automate Total Weight Calculation in Shipment Header BPM Cookbook

2. For the Directive Name, type in AutomaticWeight.

3. Add a Description - for example, Calculates total lines weight in one of the basic UOMs - g, kg, or
lb - and updates the shipment weight in the header.

4. Select the AutomaticWeight group.

5. Again, keep the default Company Scope.

Now, proceed to designing the workflow.

Link the Pre- and Post-Processing Directives

In this step, add a condition that will trigger this post directive only if the set criteria are met at the pre-processing
stage.

1. On the Post-Processing sheet, click Design.


The BPM Workflow Designer displays.

2. From the Flow Chart pane, select the Condition widget and drag it onto the canvas.
Connect the Start widget to the Condition.

64 Epicor Kinetic | Classic


BPM Cookbook Automate Total Weight Calculation in Shipment Header

3. Select the Condition widget on the canvas, and on the Properties > Condition sheet below, click New.
A new condition line is added to the grid.

4. From the drop-down in the Condition column, select the following condition:
This directive has been enabled from the specified directive.

5. Click the specified link


The Select a primary directive to depend on window displays.

6. Select the Pre stage, then from the Directive drop-down, choose AutomaticWeight and click OK.

Calculate Total Lines Weight

In this sub-step, get data from the ShipDtl database table for the current pack and UOM, and calculate total
weight.

1. Navigate to the Properties > Variables sheet and add two variables:

Name Type
dsShip CustShipTableset
totalWeight Decimal

You will use dsShip to temporarily store data you fetch from the database. totalWeight will hold the total
shipment lines weight that you will calculate in the directive.

2. Select the Fill Table by Query widget on the Setters pane and add it to the workflow.
Connect the True end of the Condition to the Fill Table by Query widget.

Epicor Kinetic | Classic 65


Automate Total Weight Calculation in Shipment Header BPM Cookbook

3. Double-click on the newly-added widget and rename it to GetDtlWeight.

4. Select the GetDtlWeight widget, and on the Properties > Actions pane, click the designed link in the
action statement.
The Compose Query window pops up. Complete these steps to configure the query:

a. From the tree view on the Phrase Build sheet, select the ERP.ShipDtl table and add it to the canvas.

b. Then, also add the ERP.ShipHead table to the canvas.


The relationship between the two table is established automatically.

c. On the canvas, click on the link that connects the two tables and define the Table Relations as follows:

ShipDtl field ShipHead field


Company Company
PackNum PackNum
WUM WeightUOM

This will link the tables by the two primary keys. Additionally, the query will select only the shipment
lines with a UOM that matches the UOM in the Header.

66 Epicor Kinetic | Classic


BPM Cookbook Automate Total Weight Calculation in Shipment Header

d. Select the ERP.ShipDtl table and define the following criteria for it:

Field Operation Filter Value


Company = BAQ CompanyID constant
PackNum = @ipPackNum argument/variable

This will limit the selection to the current Company and Pack Number.

Epicor Kinetic | Classic 67


Automate Total Weight Calculation in Shipment Header BPM Cookbook

e. On the Display Fields sheet, in the tree view, expand the ShipDtl node and select the following fields:
Company, PackNum, and TotalNetWeight.

f. Click OK to close the Compose Query window.

5. Now, click the first specified link in the action statement.


The Select Table window displays.

6. Select the dsShip.ShipDtl table and click OK.

7. Click the not configured link.


The Setup Table Mapping window displays.

8. Click Bind Automatically to link query fields to table fields.


Note Three bindings have been created automatically:

Name Type Binding


Company string field: ShipDtl_Company
PackNum int field: ShipDtl_PackNum
TotalNetWeight decimal field:
ShipDtl_TotalNetWeight

9. On the Setup Table Mapping window, click OK.

10. Finally, from the Setters pane, add a Set Argument/Variable widget to the workflow.

68 Epicor Kinetic | Classic


BPM Cookbook Automate Total Weight Calculation in Shipment Header

11. Connect the GetDtlWeight widget to the one you just added.

12. Rename the Set Argument/Variable widget to SumUpDtlWeight and configure it as follows:

a. Click the first specified link.


The Select an Argument/Variable window displays.

b. Select the totalWeight directive-level variable and click OK.

c. Click the second specified link.


The Specify C# expression window displays.

d. Add the following expression into the Editor:


dsShip.ShipDtl.Select(r => r.TotalNetWeight).Sum()

Epicor Kinetic | Classic 69


Automate Total Weight Calculation in Shipment Header BPM Cookbook

e. Click OK.

Update Shipment Header

In this step, you will fill the ShipHead table by query and define a new value for the ShipHead.Weight field.
You will then invoke the UpdateExt method of the CustShip (Customer Shipment) business object to update
the database.

1. From the Callers pane, select the Invoke BO Method widget and add it to the workflow.
Note Defining this widget first will bring in and make available for selection all the tablesets associated
with the specified service method. This will simplify adding a variable for the temporary UpdateExt
tableset.

70 Epicor Kinetic | Classic


BPM Cookbook Automate Total Weight Calculation in Shipment Header

2. Rename the newly added widget to UpdateHeadWeight.

3. Select the UpdateHeadWeight widget and configure it like this:

a. Click the specified link.


The Choose BO Method displays.

b. For Business Object, type in CustShip.

c. Click Search and select the UpdateExt method.

Epicor Kinetic | Classic 71


Automate Total Weight Calculation in Shipment Header BPM Cookbook

d. Click the not configured link.


The Setup Method Parameters window displays.

e. In the ds parameter binding, select create new variable.


The Create new variable window displays.

f. In the Name field, type in dsUpdateExt and click OK.


This creates a directive-level variable of tableset type. UpdExtCustShip is the default tableset for the
CustShip's UpdateExt method.

g. Bind the continueProcessingOnError parameter to the true expression.

h. Bind the rollbackParentOnChildError parameter to the false expression.

i. Set the remaining parameters' bindings to [ignore] and click OK.

4. Select the Fill Table by Query widget on the Setters pane and add it to the workflow. Rename it to
AddTtlDtlWeight.

72 Epicor Kinetic | Classic


BPM Cookbook Automate Total Weight Calculation in Shipment Header

5. Connect the SumUpDtlWeight widget to the Fill Table by Query widget you just added. Also connect
the new Fill Table by Query widget to the UpdateHeadWeight widget.

6. Select the AddTtlDtlWeight widget, and on the Properties > Actions pane, click the designed link in
the action statement.
The Compose Query window pops up. Complete these steps to configure the query:

a. From the tree view on the Phrase Build sheet, select the ERP.ShipHead table and add it to the canvas.

b. Select the ERP.ShipHead table and define the following criteria for it:

Field Operation Filter Value


Company = BAQ CompanyID constant
PackNum = @ipPackNum argument/variable

This will limit the selection to the current Company and Pack Number.

Epicor Kinetic | Classic 73


Automate Total Weight Calculation in Shipment Header BPM Cookbook

c. On the Display Fields sheet, in the tree view, expand the ShipHead node and select the following
fields: Company, PackNum, Weight, and SysRowID.

d. Click OK to close the Compose Query window.

74 Epicor Kinetic | Classic


BPM Cookbook Automate Total Weight Calculation in Shipment Header

7. Now, click the specified link in the action statement.


The Select Table window displays.

8. Select the dsUpdateExt.ShipHead table and click OK.

9. Click the not configured link.


The Setup Table Mapping window displays.

10. Click Bind Automatically to link query fields to table fields.


Note Four bindings have been created automatically:

Name Type Binding


Company string field: ShipHead_Company
PackNum int field: ShipHead_PackNum
Weight decimal field: ShipHead_Weight
SysRowID string field: ShipHead_SysRowID

11. Change the Weight binding and link it to the totalWeight variable instead:

Name Type Binding


Weight decimal var: totalWeight

12. On the Setup Table Mapping window, click OK.

Epicor Kinetic | Classic 75


Automate Total Weight Calculation in Shipment Header BPM Cookbook

Refresh Form Data

In this step, add a call to the GetByID method of the Customer Shipment service to refresh data on the form.

1. From the Callers pane, select the Invoke BO Method widget and add it to the workflow.

2. Rename the newly added widget to RefreshForm and connect the UpdateHeadWeight widget to it.

3. Select the RefreshForm widget and configure it like this:

a. Click the specified link.


The Choose BO Method displays.

b. For Business Object, type in CustShip.

c. Click Search and select the GetByID method.

d. Click the not configured link.


The Setup Method Parameters window displays.

e. Bind the PackNum parameter to the ipPackNum variable.

f. Bind the <return value> parameter to the ds variable.

g. Click OK.

Review and Save Directive Workflow

In this step, go over the workflow you've just created, then save the workflow and the directive.
The workflow of your directive should look like this:

76 Epicor Kinetic | Classic


BPM Cookbook Automate Total Weight Calculation in Shipment Header

1. You first linked your post-processing directive to the pre-processing one using a condition.

2. You then got weight data from the database and calculated the total weight of all the lines in the shipment.

3. Next, you queried the database again to get the CustShip tableset and added your weight sum variable to
it, then called the UpdateExt method of the CustShip BO.

4. Finally, you called the GetByID method of the CustShip BO to refresh data on the form so that you can
see the changed value without refreshing the form manually.

5. Click Save.

6. Close the BPM Workflow Designer.

7. In Method Directives Maintenance, enable and save the directive.

Test BPM Customization

In this step, create an order with multiple lines and a shipment to test the directive execution.

1. Launch Sales Order Entry.


Menu Path: Sales Management > Order Management > General Operations > Order Entry

2. From the New drop-down in the Toolbar, select New Order.

3. In the Customer field, type in dalton and press Tab.

4. From the New drop-down, select New Line, then navigate to the Lines > Detail sheet.

5. Click the Part/Rev button to search for and select part 00C1.

6. In the Order Quantity field, enter 10.

7. From the New drop-down, select New Line again.

8. Add the 00C3 part in the quantity of 10.

Epicor Kinetic | Classic 77


Automate Total Weight Calculation in Shipment Header BPM Cookbook

9. Take note of the order number. You will use it to create a shipment.

10. Save and close the order.

11. Launch Customer Shipment Entry.


Menu Path: Material Management > Shipping > Receiving > General Operations > Customer Shipment
Entry.

12. From the New drop-down in the Toolbar, select New Pack.
The Summary sheet displays.

78 Epicor Kinetic | Classic


BPM Cookbook Automate Total Weight Calculation in Shipment Header

13. In the Order Number field, enter the number of the sales order you just created and press Tab.

14. Click Mass Shipment.


Two shipment lines are added below.

15. Now click Ship All.


This sets the Inv Ship Qty to the part quantity specified in the order.

16. In the same row, click the Update button.


The Weight field displays the total weight of both shipment lines.

You can continue testing different scenarios by adding order lines for parts with other units of measure - grams
or kilograms, by using other conditions to trigger the directive, or by changing weight on a shipment line detail.

Epicor Kinetic | Classic 79


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

Set Up Optional Automation of Creating Resource for


Employee

In this example, create BPM logic that will generate a new Resource Group and Resource for an employee.
This scenario demonstrates the usage of the UpdateExt method for creating new ERP records (moreover, in this
example, you will create a parent and a child record) with pre-filling of values for some fields, including user-defined
ones (UD fields).
BPM Concepts Covered in This Example:
• Using UpdateExt to create new records
• Pre-filling required field values
• Creating a parent and a child record at once
• Updating user-defined (UD) fields
• Using Functions to deal with conflicting data tables
Also Covered in This Example:
• Customizing user interface
• Adding user-defined fields to the database
To complete this walkthrough, you need to make sure you have all required permissions and rights set up for
your user account:
• Access to the Epicor Application server where you will use the functionality of the Epicor Administration
Console or the Data Model Generator Command tool to regenerate the data model with new UD fields
• Customize Privileges enabled for the user account
• User account authorized in Functions Administrator and Functions Developer security groups.
First of all, you will add a few UD fields to the database, and controls to manage the new functionality in the UI:
• Create Resource - a check box on the Employee Maintenance form that will trigger the creation of the
Resource Group and Resource records.
• A text box on the Employee Maintenance form that will display a success report or the text of an error that
occurred during creation of new records.
• Auto Gen - a check box on the Resource Group Maintenance form (Resources > Detail) that will indicate
the resource has been created for an employee automatically.
Next, you will add a pre-processing directive that will evaluate the conditions for running the main logic. The
new records will be created only if the Create Resource option is selected.
Then, you will create a Function that will contain logic for:
• Editing the dataset of the Resource Group BO's UpdateExt method using Fill Table by Query actions.
• Running the UpdateExt method to create new Resource Group and Resource.
• Returning a "successful" message if records were created without errors or an error text if an error occurred
during creation.
Finally, you will add a post-processing directive that will:
• Be linked to the pre-processing directive.
• Invoke the Function.

80 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

• Update the current employee record with information new Resource Group and Resource if they have been
created, and reset the Create Resource check box.
• Refresh the current employee data on the Employee Maintenance form.

Add User-Defined (UD) Fields

In this step, add three UD fields to the database and regenerate the Epicor Data Model to make them available
for further operations.

1. Launch User Defined Column Maintenance.


Menu Path: System Setup > System Maintenance > UD Column Maintenance.

2. From the New drop-down in the Main Toolbar, select New Table.
The Table Search window displays.

3. Select the EmpBasic table and click OK.


The new EmpBasic_UD table is created. The Table not in database shape displays on table details.

4. From the New drop-down in the Main Toolbar, select New Column.
The Column > Detail sheet displays for editing.

5. Add a new column with the following properties:


• Column Name - CreateResource.
Note that when you tab out of this field a _c postfix is automatically added to the column name.
• Data type - Boolean.

Epicor Kinetic | Classic 81


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

6. Add another column with the following properties:


• Column Name - RecordErrors.
• Data type - String.
• Format - x(1000).

7. Save the table.

8. Now, from the New drop-down in the Main Toolbar, select New Table again.

9. In the Table Search window, select the ResourceGroup table and click OK.

10. Add a new column to this table with the following properties:
• Column Name - AutoGenerated.
• Data type - Boolean.

82 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

11. Save the changes and keep the User Defined Column Maintenance program open.

Regenerate Data Model

In this sub-step, add your new columns to the Data Model so that they become available for customization.
In this example, regenerate the model from the Epicor Administration Console
Note For the detailed description of this process, please refer to the EAC help documentation.

1. On the Epicor server, launch Epicor Administration Console (EAC).

2. In the navigation panel on the left, expand the Database Server Management and drill down to your
database node - for example, ERP102700.

3. On the Actions panel on the right, select Regenerate Data Model.


The Generate Data Model dialog pops up.

4. Specify the credentials for database connection and press Generate.

Epicor Kinetic | Classic 83


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

Note Data Model regeneration may take a while.

5. Once it has been successfully completed, in the navigation, select your ERP instance and click Recycle IIS
Application Pool on the right-hand Actions panel.

6. After the application pool has been successfully recycled, on the User Defined Column Maintenance form,
click Refresh.
Both, the EmpBasic_UD and ResourceGroup_UD table details now display two green shapes - Table in
Sync and Data Model in sync.

You can now proceed to customizing the UI.

Customize User Interface

In this step, add UI controls and bind them to the new UD fields.
On the Kinetic Home Page, expand the Overflow menu and select Developer Mode (Off) to turn on developer
mode.

84 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

Note To access this functionality, Customization Privileges must be enabled for your user account.

Modify Employee Maintenance UI

In this sub-step, add a check box, label, and text box to the Employee Maintenance program UI.

1. Launch Employee Maintenance.


Menu Path: Production Management > Job Management > Setup > Employee.

2. On the Select Customization window that pops up, select the Base Only option to make sure you work
directly with the base form UI, and all customizations for this form (if any) are disabled. Then click OK.

The Employee Maintenance program launches.

3. Navigate to the Production Information sheet.

Epicor Kinetic | Classic 85


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

4. In the Main Menu, go to Tools > Customization.


The Customization Tools Dialog window displays.

5. On the Customization Tools Dialog, go to Tools > ToolBox.

The floating Toolbox panel appears.

6. Select EpiCheckBox, then click on the form to indicate where you want to place it.
On the Select Layer Type dialog window that pops up, choose Customization and click OK.

86 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

7. In the Toolbox, select the EpiLabel control and add it to the form next to the check box.

8. Select the newly added label on the form and edit its properties (Customization Tools Dialog > Properties):

Property Value
(Name) lblCreateResource
Text Create Resource

Epicor Kinetic | Classic 87


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

9. Now, select the check box on the form and edit its properties:

Property Value
EpiBinding EmpBasic.CreateResource_c (select from drop-down
list)
EpiLabel lblCreateResource (select from drop-down list) - this
creates a binding between the check box and label,
so if you move the check box, the label will move
with it.
(Name) chkCreateResource

88 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

10. In the Toolbox, select the EpiTextBox control and add it to the form below the check box and the label.
Make it wide enough to display a possible error text.
Specify a (Name) for it - for example, txtErrors.

Epicor Kinetic | Classic 89


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

11. In the Customization Tools Dialog, click Save to save the layer.
The Customization Save Dialog displays.

90 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

12. Type in a name - for example, CreateResource, and click Save.


You can keep the Customization Comment blank and click OK.

13. Close Customization Tools Dialog.

14. Note the new controls on the form.

15. Close Employee Maintenance.

Modify Resource Group Maintenance UI

In this sub-step, add a check box and label to the Resource Group Maintenance program UI.

1. Make sure the Developer Mode is still on and launch Resource Group Maintenance.

Epicor Kinetic | Classic 91


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

Menu Path: Production Management > Scheduling > Setup > Resource Group.

2. On the Select Customization window that pops up, select Base Only and click OK.
The Resource Group Maintenance program launches.

3. Navigate to the Resources > Detail sheet.

4. In the Main Menu, go to Tools > Customization.


The Customization Tools Dialog window displays.

5. On the Customization Tools Dialog, go to Tools > ToolBox.


The floating Toolbox panel appears.

6. Select EpiCheckBox, then click on the form to indicate where you want to place it.
On the Select Layer Type dialog window that pops up, choose Customization and click OK.

7. In the Toolbox, select the EpiLabel control and add it to the form next to the check box.

8. Select the newly added label on the form and edit its properties (Customization Tools Dialog > Properties):

Property Value
(Name) lblAutoGen
Text Auto Gen

9. Now, select the check box on the form and edit its properties:

92 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

Property Value
EpiBinding ResourceGroup.AutoGenerated_c (select from
drop-down list)
EpiLabel lblAutoGen
(Name) chkAutoGen

10. In the Customization Tools Dialog, click Save to save the layer.
The Customization Save Dialog displays.

11. Type in a name - for example, AutoGenerated, and click Save.


You can keep the Customization Comment blank and click OK.

12. Close Customization Tools Dialog.

13. Note the new control on the form:

14. Close Resource Group Maintenance.

Epicor Kinetic | Classic 93


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

15. Turn off Developer Mode.

Add Pre-Processing Directive

In this step, add a pre-processing directive to set conditions for execution of the post-processing directive.

1. Launch Method Directives Maintenance.


Menu Path: System Management > Business Process Management > Method Directives Maintenance.

2. On the Detail sheet, click the Method Code button.


The Method Search window displays.

3. On the Basic sheet, for Service Name, type in EmpBasic, and in the Where Method Name Starts At
field, enter upd.

4. Click Search.

5. Select the Update method of the EmpBasic business object and click OK.

6. In the Toolbar, from the New drop-down, select New Pre-Processing.

94 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

The Pre-Processing sheet displays on the form.

7. For Directive Name, enter CheckForResource.

8. Add a Description - for example, Defines conditions for the AutoCreateResource post-processing
directive.

9. In the Group field, type in AutoCreateResource.

10. Keep the default Company Scope.

11. Save the directive.

Move on to the next step to design this directive's workflow.

Define Conditions for Executing Post-Processing Directive

In this sub-step, define the condition that will trigger the post-processing directive.

1. On the Pre-Processing sheet with your directive details, click Design.


The BPM Workflow Designer window displays.

2. From the Flow Chart pane on the left, select the Condition widget and drag it onto the canvas.
Connect the Start widget to the Condition.

Epicor Kinetic | Classic 95


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

3. Select the Condition widget and on the Properties > Condition sheet below the canvas, click the New
icon.
A new condition line is added.

4. From the drop-down in the Condition column, select The specified field has been changed from any
to another statement.
Define its variables as follows:

a. Click the specified link.


The Select Table Field(s) window displays.

96 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

b. In the Table field, select ds.EmpBasic.

c. Then select the CreateResource_c field and click OK.


Tip UD fields are at the very end of the field list.

d. Click the any link.

e. In the Specify a Value window, type in false for Value.

f. Click the another link.

g. In the Specify a Value window, type in true for Value.

5. From the Other pane, select the Enable Post Directive widget and add it to the workflow.
Connect the True end of the Condition widget to Enable Post Directive.

Epicor Kinetic | Classic 97


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

6. Save the workflow.

7. Close the BPM Workflow Designer.

8. Enable and save the CheckForResource pre-processing directive.

Keep the Method Directives Maintenance open and move on to first creating a Function that will be invoked
from the post-processing directive.

98 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

Add Function to Create New Resource and Resource Group

In this sub-step create a Function that will create new Resource Group and Resource records.
You will design this part of directive workflow as a Function to avoid compilation failure due to the conflict of
tablesets with identical names both in Employee and Resource Group. Epicor Functions are isolated units of
business logic that execute in their own exclusive context. In this example, you will use a Function to invoke the
UpdateExt method of the Resource Group BO.

1. Launch Epicor Functions Maintenance.


Menu Path: System Management > Business Process Management > Epicor Functions Maintenance.
Note Your user account must be assigned to the Functions Administrator and Functions Developer
Security Groups.

2. Select New > Add Library.

The Summary sheet displays for editing.

3. In the Library field, type in AutoResourceGroup and press Tab.

4. Add a Description - for example, AutoResourceGroup.

5. Now go to the References > Services sheet and click Add.


The Service Search window displays.

Epicor Kinetic | Classic 99


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

6. Select the Erp.BO.ResourceGroup service and click OK.

7. Move to the References > Tables sheet and add the ERP.Plant table.

You will create a query against this table to get the current Plant and Company IDs.

8. Next, move on to the Security sheet.

100 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

9. Add your current company - in this example, Epicor Education, to the Authorized Companies list.

10. From the New drop-down in the Main Toolbar, select Add Widget Function.

The Function sheet displays.

Epicor Kinetic | Classic 101


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

11. For the Function ID, type in createResourceAndGroup.

12. Add a Description - for example: Creates Resource Group and Resource for Employee.

13. On the Function > Signature sheet, add one input parameter:

Name Type
groupID System.String
department System.String

Note In post-processing, we will pass the current Employee ID (EmpBasic.Emp.ID) to the groupID
Function parameter. We will use the Employee ID for the new Resource Group and Resource IDs to
simplify the example. Creating a new Resource Group requires the employee's department.

14. Add an output parameter that will return error text if an error occurs when adding new rows.

Name Type
errorText System.String

15. On the Function > Signature sheet, click Complete.

16. Save the library and Function.

You can now design the Function workflow.

Fill Tables for the New Resource Group and Resource and Invoke UpdateExt

In this sub-step, fill the ResourceGroup and Resource tables with values required for adding new rows.
To add two new rows to the ResourceGroup and Resource tables in the ResourceGroup.UpdateExt dataset, you
can only use a Fill Table by Query action. You will need any query for the sake of having a query. In this example,
query the Plant table to get the Plant and Company IDs that you will map to the dsUpdExt.ResourceGroup table.

102 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

Tip With Fill Table by Query actions, you update the local copy of the method's dataset. This local copy
of the dataset will be stored in a Function-level variable of tableset type. Creating and defining this variable
is easier when you first define the method you are going to invoke. This way, the variable type is created
by the system automatically. Doing this the other way around requires that you know exactly what tableset
you are looking for and where.
In this example, let's use this trick and define the BO method first.

1. On the Function sheet of the Epicor Functions Maintenance program, click Design.
The Function Designer launches.

2. From the Callers pane, select the Invoke BO Method widget and add it to the workflow.
Do not connect any other widgets to it just yet.

3. Rename the newly added widget to ResGrp.UpdateExt.


Configure the action like this:

a. Click the specified link.


The Method Search window displays.

Epicor Kinetic | Classic 103


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

b. Select the UpdateExt method of the ResourceGroup service and click OK.

c. Click the not configured link.


The Setup Method Parameters window pops up.

d. For the ds in-out parameter, create a new variable - dsUpdExt.

e. Bind the continueProcessingOnError and rollbackParentOnChildError parameters to the true


expression.

f. For the errorsOccurred parameter, create a new variable - errorOccurred.

g. For <return value>, create another variable - dsErrors.

h. Click OK.

4. From the Setters pane, select the Fill Table by Query widget and drag it onto the canvas.

104 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

Rename it to something like Fill ResourceGroup.

5. Connect the Start widget to the Fill ResourceGroup widget.

6. Configure the Fill ResourceGroup action:

a. Click the designed link.


The Compose Query window displays.

b. From the table list on the left, select the ERP.Plant table.

Epicor Kinetic | Classic 105


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

c. Select the table on the canvas and navigate to the Table Criteria sheet below.
Add two criteria:

AndOr ( Not Field Operation Filter Value )


Plant1 = BAQ CurrentPlant constant
And Company = BAQ CompanyID constant

Tip As we are using a Fill By Table action, we need to have some data in a query to identify how
many rows to create. This is why we need one single row from the Plant table.

d. Navigate to the Display Fields sheet and select at least one field to display - for this example, pick two:
Company and Plant1.

e. Click the specified link.

f. In the Select Table window, choose the dsUpdExt.ResourceGroup table and click OK.

g. Click the not configured link.


The Setup Table Mapping window displays.

106 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

h. Click Bind Automatically.


Two bindings were created automatically - Company and Plant were bound to the corresponding fields
from the query. Add a few more bindings.

i. Bind the ResourceGrpID, BackflushEmpID, and Description fields to the Function's groupID input
parameter.

j. Bind the JCDept field to the Function's department input parameter.

k. Set the Location field to false to prevent more required values.

l. Bind the AutoGenerated_c field to the true expression.

m. Specify the following expression for RowMod - "A".

n. Click OK to close the window.

7. From the Setters pane, select another Fill Table by Query widget and drag it onto the canvas.
Rename it to Fill Resource.

Epicor Kinetic | Classic 107


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

8. Connect the Fill ResourceGroup widget to the Fill Resource widget.

9. Configure the Fill Resource action:

a. Click the designed link.


The Compose Query window displays.

b. Design the query the same way you did in Step 6 (b,c,d).

c. Click the specified link.

d. In the Select Table window, choose the dsUpdExt.Resource table and click OK.

e. Click the not configured link.


The Setup Table Mapping window displays.

108 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

f. Click Bind Automatically.


Two bindings were created automatically - Company and Plant were bound to the corresponding fields
from the query. Add a few more bindings.

g. Bind the ResourceGrpID, ResourceID, and Description fields to the Function's groupID input parameter

h. Set the Location field to false to prevent more required values.

i. Specify the following expression for RowMod - "A" where A stands for Added.

j. Click OK to close the window.

10. Connect the Fill Resource widget to the ResGrp.UpdateExt widget.

Epicor Kinetic | Classic 109


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

Handle Method Response

In this sub-step, add logic that will process the method response.
Add a condition that will evaluate the errorOccurred variable. If an error occurred during the update process
(errorOccurred = true), set the errorText output parameter value to one expression, else (errorOccurred = false)
to another.

1. In the Flow Chart pane, select the Condition widget and add it to the workflow.
Connect ResGrp.UpdateExt to Condition 0.

2. On the Actions sheet of the Properties panel, click New and select the following condition:
The specified argument/variable is equal to the specified expression.

3. Configure the condition:

a. Click the first specified link.

b. In the Select an Argument/Variable dialog, choose the errorOccurred parameter and click OK.

c. Keep the is equal to segment.

d. Click the second specified link.

e. In the Specify C# expression window, type in true and click OK.

4. From the Setters pane, select the Set Argument/Variable widget and add it to the canvas.
Connect the True end of the Condition to the Set Argument/Variable you just added.

110 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

5. Select and configure the new widget:

a. Click the first specified link.

b. In the Select an Argument/Variable window, choose the errorText parameter (argument) and click
OK.

c. Click the second specified link.

d. In the Specify C# expression window, enter the following expression to get the first row:
dsErrors.BOUpdError.Select (r=>r.ErrorText).FirstOrDefault()

Epicor Kinetic | Classic 111


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

6. From the Setters pane, select another Set Argument/Variable widget and add it to the canvas.
Connect the False end of the Condition to the Set Argument/Variable you just added.

7. Select and configure the new widget:

a. Click the first specified link.

b. In the Select an Argument/Variable window, choose the errorText parameter (argument) and click
OK.

c. Click the second specified link.

d. In the Specify C# expression window, enter the following expression to get the first row:
"Resource Group and Resource created successfully."

112 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

8. Review and Save the workflow.

9. Close the Designer.

10. Back in Epicor Functions Maintenance, save the library and Function.

Epicor Kinetic | Classic 113


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

11. Publish the library (Actions > Promote Library to Production) and close the program.

Add Post-Processing Logic

In this sub-step, design the post-processing directive.

1. In the Main toolbar of the Method Directives program, select New > New Post-Processing.

The Post-Processing > Detail sheet displays.

2. For the Directive Name, type in:


AutoCreateResource.

3. Enter a Description - for example:

114 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

Creates new Resource Group and Resource and updates Employee.

4. In the Group field, select the AutoCreateResource.

5. Click Design.
The BPM Workflow Designer displays.
Move on to the next sub-step to design the directive workflow.

Link to Pre-Processing and Invoke Function

In this sub-step, add a condition to execute the directive only if the pre-processing criteria were satisfied.
Also, invoke the Function that creates new Resource Group and Resource records.

1. From the Flow Chart pane, select the Condition widget and add it to the canvas.
Connect the Start widget to the Condition 0 widget.

2. Navigate to the Properties > Condition 0 sheet and click New.


A new condition line appears in the grid.

3. Select the following statement:


This directive has been enabled from the specified directive.

a. Click the specified link.


The Select a primary directive to depend on window displays.

b. Verify the Pre radio button is selected and choose CheckForResource from the Directive drop-down.

c. Click OK.

4. From the Callers pane, select Invoke Function and drag it onto the canvas.

Epicor Kinetic | Classic 115


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

Connect the True end of the Condition widget to the Invoke Function widget.

5. Select the Invoke Function widget and set it up as follows:

a. Keep the Synchronously parameter as is.

b. Click the library link.


The Library Search window displays.

c. Select the AutoResourceGroup library and click OK.

d. Click the function link.

e. On the Function Search window, select the createResourceAndGroup Function and click OK.

f. Finally, click the not configured link.


The Setup Function Parameters window displays.

g. Bind the groupID Function parameter to the EmpID field of the Employee table using the following
expression: dsEmpBasicRow.EmpID.

h. Bind the department Function parameter to the JCDept field of the Employee table using the following
expression: dsEmpBasicRow.JCDept.

i. For the errorText out parameter, create a new directive-level variable - errorText.

j. Click OK to complete the setup.

Update Employee Record with Created Resource Data

In this sub-step, update the Employee record with information on the created Resource Group and Resource.
Use the Fill Table by Query action to specify Resource Group ID, Resource ID, and Create Resource check box
values, and run the UpdateExt method of the Employee service to update the current employee record.

116 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

Let us first add the EmpBasic.UpdateExt method and define its parameters, and then fill the local UpdateExt
dataset just like we did in the Function before.

1. From the Callers pane, select the Invoke BO Method widget and add it to the workflow.
Do not connect any other widgets to it just yet.

2. Rename the newly added widget to Emp.UpdateExt.


Configure the action like this:

a. Click the first specified link.


The Method Search window displays.

b. Select the UpdateExt method of the EmpBasic service and click OK.

c. Click the second specified link.


The Setup Method Parameters window pops up.

d. For the ds in-out parameter, create a new variable - dsEmpUpdExt.

e. Bind the continueProcessingOnError and rollbackParentOnChildError parameters to the false


expression.

f. For errorsOccurred and <return value> parameters, set the bindings to [ignore].

g. Click OK.

3. Now, from the Setters pane, select the Fill Table by Query widget and drag it onto the canvas.
Rename it to something like Fill Employee Table.

Epicor Kinetic | Classic 117


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

4. Connect the Invoke Function widget to the Fill Employee Table widget.

5. Connect the Fill Employee Table widget to the Emp.UpdateExt widget.

6. Configure the Fill Employee Table action:

a. Click the designed link.


The Compose Query window displays.

b. From the table list on the left, select the ds.EmpBasic table.

118 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

c. Navigate to the Display Fields sheet and select two fields to display - Company and EmpID.

d. Click the specified link.

e. In the Select Table window, choose the dsEmpUpdExt.EmpBasic table and click OK.

f. Click the not configured link.


The Setup Table Mapping window displays.

Epicor Kinetic | Classic 119


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

g. Click Bind Automatically.


Two bindings were created automatically - Company and EmpID were bound to the corresponding
fields from the query. Add a few more bindings.

h. Bind the ResourceGrpID field to the following expression:


errorText == "Resource Group and Resource created successfully." ? dsEmpB
asicRow.EmpID : dsEmpBasicRow.ResourceGrpID.

i. Bind the ResourceID field to the following expression:

120 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

errorText == "Resource Group and Resource created successfully." ? dsEmpB


asicRow.EmpID : dsEmpBasicRow.ResourceID.

Note These two expressions above mean that if Resource Group and Resource have been created
successfully, and the errorText variable contains a success message, the ResourceGrpID and
ResourceID fields will be assigned the current Employee ID value that we know is what we used
to create the new records' IDs, else these fields preserve their original values.

j. Bind the RecordErrors_c field to the directive-level errorText variable.

k. Set the CreateResource_c field to false to reset the Create Resource check box.

l. Click OK to close the window.

Refresh Data on Employee Maintenance Form

In this sub-step, invoke the GetByID method of the Employee service to automatically refresh data on the form.

1. From the Callers pane, select the Invoke BO Method widget and add it to the workflow.

Epicor Kinetic | Classic 121


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

2. Rename the newly added widget to Emp.GetById.

3. Connect the Emp.UpdateExt widget to it.

4. Select the Emp.GetById widget and configure it like this:

a. Click the specified link.


The Method Search window displays.

b. For Service Name, type in empbasic.

c. Click Search and select the GetByID method.

122 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

d. Click the not configured link.


The Setup Method Parameters window displays.

e. Bind the empID parameter to the following expression - dsEmpBasicRow.EmpID.

f. Bind the <return value> parameter to the ds variable.

g. Click OK.

Review the Workflow and Enable Directive

In this sub-step, go over the workflow you've just created, then save the workflow and the directive.

1. Make sure your workflow looks similar to this:

2. Save the workflow.

Epicor Kinetic | Classic 123


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

3. Close the BPM Workflow Designer.

4. In Method Directives, enable and save the directive.

You can now test the custom BPM logic you've just designed.

Test BPM Customization

In this step, test the directives.


Important To keep this example simpler and shorter, we did not deploy the UI customizations for the
Employee Maintenance and Resource Group Maintenance programs. To test your new logic, in the ERP
client, turn on the Developer Mode again. When you launch a program, select the customization layer that
you have previously created for it.

1. Launch Employee Maintenance.

2. In the Select Customization dialog, select the CreateResource layer and press OK.

124 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

Employee Maintenance displays.

3. In the ID field, type in 105 if you are using the Demo DB, and press Tab.

Note If you use another non-education database, you might need to search for an existing employee
or create a new one.

4. Navigate to the Production Information sheet.

Epicor Kinetic | Classic 125


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

5. Select the Create Resource check box and Save the record.
Note that the form has been updated:

• Resource Group and Resource fields remain blank.


• Create Resource check box is cleared.
• The text box below it contains an error message: A valid Department is required.

6. From the Department drop-down, select a department - for example, Assembly Department.

7. Select the Create Resource check box again and Save the record.

126 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

Note that the form has been updated:

• Resource Group and Resource fields contain the IDs of the created records.
• Create Resource check box is cleared.
• The text box below it contains a success message: Resource Group and Resource created successfully.

8. Now open the Resource Group Maintenance program.

9. In the Select Customization dialog, select the AutoGenerated layer and press OK.

Epicor Kinetic | Classic 127


Set Up Optional Automation of Creating Resource for Employee BPM Cookbook

Resource Group Maintenance displays.

10. In the Resource Group field, type in 105 and press Tab.
The group details display on the form.

128 Epicor Kinetic | Classic


BPM Cookbook Set Up Optional Automation of Creating Resource for Employee

11. Navigate to the Resources > Detail sheet and display resource 105.
Note that the Auto Gen check box is selected.

Epicor Kinetic | Classic 129


Add New Misc Charge to Order Automatically BPM Cookbook

Add New Misc Charge to Order Automatically

In this example, add custom logic to automatically generate a customer-specific Misc Charge in a newly created
sales order.
You will customize the logic of the MasterUpdate method of the Sales Order (SalesOrder) service to automatically
add a Freight Misc Charge to any new order created for Addison.
BPM Concepts Covered in This Example:
• Using Update to create a new record
• Creating initial filling of required fields
You will first create a pre-processing directive that will evaluate the defined conditions for triggering the addition
of a new Misc Charge to the Order Header. The Freight Misc Charge will be added only:
• when a new order is created and saved for the first time, and
• if the customer is Addison.
You will then create a post-processing directive that will execute only if the above criteria are satisfied at the
pre-processing stage. The post-processing directive will implement the following logic:
• It will obtain the number of the new order from its dataset and will assign it to a directive-level variable. It
will use this order number to get the most up-to-date version of the sales order tableset after the main logic
of the MasterUpdate has been completed. It will then put this order data into another variable of Tableset
type for further modification.
• Next, it will call the GetNewOHOrderMsc method of the Sales Order service to create a new empty row in
the OHOrderMsc table.
• After that, it will set a FRGT value to the MiscCode field in this table and pass the updated sales order dataset
to the ChangeMiscCharge method that automatically fires when the MiscCode field value is changed. This
method adds other default values for the specified miscellaneous charge code.
• Then, it will invoke the SalesOrder.Update method to bring all the changes made to the dataset into the
database.
• Finally, it will call the SalesOrder.GetByID method to update Misc Charge data on the Sales Order Entry
form.

Add a Pre-Processing Directive

In this step, add a pre-processing directive to set conditions for execution of the post-processing directive.

1. Launch Method Directives Maintenance.


Menu Path: System Management > Business Process Management > Method Directives Maintenance.

2. On the Detail sheet, click the Method Code button.


The Method Search window displays.

130 Epicor Kinetic | Classic


BPM Cookbook Add New Misc Charge to Order Automatically

3. On the Basic sheet, for Service Name, type in salesorder, and in the Where Method Name Starts At
field, enter master.

4. Click Search.

5. Select the MasterUpdate method of the SalesOrder business object and click OK.

6. In the Toolbar, from the New drop-down, select New Pre-Processing.

The Pre-Processing > Detail sheet displays on the form.

Epicor Kinetic | Classic 131


Add New Misc Charge to Order Automatically BPM Cookbook

7. For Directive Name, enter CheckForMiscCharge.

8. Add a Description - for example, Triggers the post-processing directive only when a new sales order
is added for Addison.

9. In the Group field, type in AutoMiscCharge.

10. Keep the default Company Scope.

11. Save the directive.

Move on to the next step to design this directive's workflow.

Design Directive Workflow

In this sub-step, define the condition that will trigger the post-processing directive.

1. On the Pre-Processing > Detail sheet with your directive details, click Design.
The BPM Workflow Designer window displays.

2. From the Flow Chart pane on the left, select the Condition widget and drag it onto the canvas.
Connect the Start widget to the Condition.

132 Epicor Kinetic | Classic


BPM Cookbook Add New Misc Charge to Order Automatically

3. Select the Condition widget and on the Properties > Condition sheet below the canvas, click the New
icon.
A new condition line is added.

4. From the drop-down in the Condition column, select There is at least one updated row in the specified
table statement.
Define its variables as follows:

a. From the updated drop-down, select added.

b. Click the specified link.


The Select Table Field(s) window displays.

c. In the Table field, select ds.OrderHed.

The post-processing directive will execute only when a new order is added.

5. Add another condition line. Keep the default And operator and select the following statement:
The specified argument/variable is equal to the specified expression.

6. Configure the second condition as follows:

a. Click the first specified link.


The Select an Argument/Variable window displays.

b. Select the iCustNum method argument (parameter) and click OK.

Epicor Kinetic | Classic 133


Add New Misc Charge to Order Automatically BPM Cookbook

c. Keep the default is equal to property.

d. Click the second specified link.


The Specify C# expression window displays.

e. In the Editor, type in 2 and click OK.

The post-processing directive will fire only for Addison.

7. From the Other pane, select the Enable Post Directive widget and add it to the workflow.
Connect the True end of the Condition widget to Enable Post Directive.

8. Save the workflow.

9. Close the BPM Workflow Designer.

10. Enable and save the CheckForMiscCharge pre-processing directive.

134 Epicor Kinetic | Classic


BPM Cookbook Add New Misc Charge to Order Automatically

Keep the Method Directives Maintenance open and move on to creating the post-processing logic.

Add a Post-Processing Directive

1. In Method Directives Maintenance, from the New drop-down, select New Post-Processing.

The Post-Processing sheet displays.

Epicor Kinetic | Classic 135


Add New Misc Charge to Order Automatically BPM Cookbook

2. For the Directive Name, type in CreateMiscCharge.

3. Add a Description - for example, Creates a Freight misc charge when a new order is added for
Addison.

4. Select the AutoMiscCharge group.

5. Again, keep the default Company Scope.

Proceed to designing the workflow.

Check for Pre-Processing Condition

In this step, add a condition that will trigger this post directive only if the set criteria are met at the pre-processing
stage.

1. On the Post-Processing sheet, click Design.


The BPM Workflow Designer displays.

2. From the Flow Chart pane, select the Condition widget and drag it onto the canvas.
Connect the Start widget to the Condition.

136 Epicor Kinetic | Classic


BPM Cookbook Add New Misc Charge to Order Automatically

3. Select the Condition widget on the canvas, and on the Properties > Condition sheet below, click New.
A new condition line is added to the grid.

4. From the drop-down in the Condition column, select the following condition:
This directive has been enabled from the specified directive.

5. Click the specified link


The Select a primary directive to depend on window displays.

6. Select the Pre stage, then from the Directive drop-down, choose CheckForMiscCharge and click OK.

Get Order Number and Dataset

In this step, obtain order number and dataset and get to store them in directive-level variables.

1. Navigate to Properties > Variables and add two directive-level variables per the table below:

Name Type
dsTemp SalesOrderTableset
localOrderNum Integer

The localOrderNum variable will store the current order number obtained from the SalesOrder dataset.
You will use it as a parameter for calling the Sales Order's GetByID method. You will use the dsTemp
variable to temporarily store the sales order data returned by this method and all directive modifications to
it.

2. From the Setters pane, add a Set Argument/Variable widget to the workflow.

Epicor Kinetic | Classic 137


Add New Misc Charge to Order Automatically BPM Cookbook

Rename the newly added widget to GetOrderNum and connect the True end of the Condition widget
to GetOrderNum.

3. Configure the GetOrderNum action as follows:

a. Click the first specified link.


The Select an Argument/Variable window displays.

b. Select the localOrderNum directive-level variable and click OK.

c. Click the second specified link.


The Specify C# expression window displays.

d. Add the following expression into the Editor:


dsOrderHedRow.OrderNum

e. Click OK.

4. Now, from the Callers pane, select Invoke BO Method and drag it onto the canvas.
Rename the widget to GetOrderDS, and connect the GetOrderNum widget to GetOrderDS.

138 Epicor Kinetic | Classic


BPM Cookbook Add New Misc Charge to Order Automatically

5. Select the GetOrderDS widget, and on the Properties > Actions tab, click the specified link in the action
statement.
The Choose BO Method window displays. On the Basic sheet:

a. In the Business Object field, type in salesorder.

b. In the Where Method Name Start At field, enter getby.

6. Click Search.

7. Select the GetByID method from the results and click OK.

8. Now, click the not configured link in the statement.


The Setup Method Parameters window displays.

Epicor Kinetic | Classic 139


Add New Misc Charge to Order Automatically BPM Cookbook

9. Bind the OrderNum method parameter to the localOrderNum variable and the output parameter of the
SalesOrderTableset type to the dsTemp variable.

10. Click OK.

Create New Freight Misc Charge

In this step, create a new Misc Charge line and set its Charge ID to Freight.

1. From the Callers pane, select another Invoke BO Method widget and add it to the workflow.
Change its name to GetMiscCharge.

140 Epicor Kinetic | Classic


BPM Cookbook Add New Misc Charge to Order Automatically

2. Connect GetOrderDS to GetMiscCharge.

3. Select the GetMiscCharge widget and click the specified link in its action statement.
The Method Search window displays.

4. Search for and select the GetNewOHOrderMisc method of the SalesOrder service BO.

Epicor Kinetic | Classic 141


Add New Misc Charge to Order Automatically BPM Cookbook

This method creates a new empty Misc Charge line for an order.

5. Once you selected the method, click the not configured link to set up its parameters:

a. Bind the ds in-out method parameter to the dsTemp variable.

142 Epicor Kinetic | Classic


BPM Cookbook Add New Misc Charge to Order Automatically

b. Bind the orderNum input parameter to localOrderNum.

c. Bind the orderLine input parameter to the following expression:


0

d. Click OK.

6. From the Setters pane, select the Set Field widget and drag it onto the canvas.
Rename it to SetMiscCode. You will use this action to set one of the predefined codes - FRGT (Freight)-
for the newly created miscellaneous charge.

7. Connect the GetMiscCharge widget to SetMiscCode.

8. Select the SetMiscCode and click the first specified link.


The Select Table Field(s) window displays.

Epicor Kinetic | Classic 143


Add New Misc Charge to Order Automatically BPM Cookbook

a. From the Table drop-down, choose the dsTemp.OHOrderMsc table.

b. Then, select MiscCode from the list of table fields.

c. Click OK.

9. Change the changed row property to the added row.


Tip If you keep the changed row option, this will include added rows too.

10. Click the second specified link.


The Specify C# expression window pops up.

144 Epicor Kinetic | Classic


BPM Cookbook Add New Misc Charge to Order Automatically

11. In the Editor, type in "FRGT" and click OK.


FRGT is the system code for the Freight Misc Charge.

12. Add another Invoke BO Method widget to the workflow.


Rename it to ChangeMiscCode.

13. Connect SetMiscCode to ChangeMiscCode.

Epicor Kinetic | Classic 145


Add New Misc Charge to Order Automatically BPM Cookbook

14. Configure the ChangeMiscCode widget as folllows:

a. Click the specified link.


The Method Search window displays.

b. Search for and select the ChangeMiscCode method.


This method is invoked by the system when the value of the MiscCode field (Charge ID in the UI) is
changed.

c. Click the not configured link.


The Setup Method Parameters window pops up.

d. Bind the ds in-out method parameter to the dsTemp variable.

146 Epicor Kinetic | Classic


BPM Cookbook Add New Misc Charge to Order Automatically

e. Bind the tableName input method parameter to the following expression:


"OHOrderMisc"

f. Click OK.

Update Sales Order and Refresh Data on the Form

In this step, invoke the Update method of the Sales Order service to bring your changes into the database and
the GetByID method to refresh data on the form.

1. From the Callers pane, select the Invoke BO Method widget again and add it to the workflow.
Rename it to UpdateSalesOrder.

2. Connect ChangeMiscCode to UpdateSalesOrder.

3. Select the UpdateSalesOrder widget on the canvas, then click the specified link in its action statement.
The Method Search window appears.

Epicor Kinetic | Classic 147


Add New Misc Charge to Order Automatically BPM Cookbook

4. Search for and select the Update method of the SalesOrder service BO.
In the statement, it should display as Erp.SalesOrder.Update.

5. Click the not configured link to set up method parameters.

a. Bind the ds in-out parameter to the dsTemp variable that now contains a new Misc Charge line.

b. Click OK.

6. Finally, add another Invoke BO Method widget onto the canvas.


Rename it to RefreshFormData.

148 Epicor Kinetic | Classic


BPM Cookbook Add New Misc Charge to Order Automatically

7. Connect the UpdateSalesOrder widget to the RefreshFormData widget.

8. Select the RefreshFormData widget on the canvas and click on the specified link in its action statement.
The Method Search window displays.

9. Search for and select the GetByID method of the SalesOrder service BO.
In the statement, it should display as Erp.SalesOrder.GetByID.

10. Click the not configured link to set up method parameters.

Epicor Kinetic | Classic 149


Add New Misc Charge to Order Automatically BPM Cookbook

a. Bind the orderNum input parameter to the localOrderNum variable.

b. Bind the <return value> out parameter to the ds argument (parameter) of the
SalesOrder.MasterUpdate method.

c. Click OK.

Review and Save Directive

In this step, go over the workflow to make sure everything has been set up correctly, and save the directive.
In the BPM Workflow Designer, you directive should look similar to this:

1. You first set a condition that's checking for a permission from the pre-processing directive to execute
post-processing logic. It executes only if set criteria are met at the pre-processing stage.

2. Secondly, you obtain the order number from the Sales Order dataset and call the SalesOrder.GetByID
method to get the most recent version of the current sales order data from the database.

150 Epicor Kinetic | Classic


BPM Cookbook Add New Misc Charge to Order Automatically

3. Next, you call the SalesOrder.GetNewOHOrderMsc method that creates a new Misc Charge record for
the order. You then pre-fill the MiscCode field (Charge ID in the UI) of the new Misc Charge row with a
code for a Freight Charge. The change of the Charge ID value triggers the ChangeMiscCode method. You
feed the modified Sales Order dataset with added Misc Charge row to it.

4. You then invoke the Update method of the SalesOrder BO to bring your changes into the database.

5. Finally, you call the SalesOrder.GetByID method to display the most actual sales order data, including the
new Misc Charge line, from the database.

6. Additionally, verify you have defined two directive-level variables: localOrderNum (integer) and dsTemp
(SalesOrderTableset).

7. Save the workflow and close the BPM Workflow Designer.

8. Enable and save the directive in Method Directive Maintenance.

Test BPM Customization

In this step, test the enabled directive.

1. Launch Sales Order Entry.


Menu Path: Sales Management > Order Management > General Operations > Order Entry.

2. From the New drop-down in the Toolbar, select New Order.


The Summary sheet displays for editing.

3. In the Customer field, type in addison and press Tab.


The details for Addison are uploaded to the form.

4. Save the order.

5. Note a new Freight Misc Charge has been added.

Epicor Kinetic | Classic 151


Add New Misc Charge to Order Automatically BPM Cookbook

6. Now create a new order for Dalton.


Note that no Misc Charge is automatically added to the order when you save it.

152 Epicor Kinetic | Classic


BPM Cookbook Delete Multiple Part Records with Updatable BAQ

Delete Multiple Part Records with Updatable BAQ

In this example, use an Updatable Business Activity Query (UBAQ) to delete multiple part records from the
database.
You will use a query as a convenient way of selecting specific part records to delete. You will then modify the
base logic of the query's Update method where you will invoke the Part BO UpdateExt method for record
deletion.
BPM Concepts Covered in This Example:
• Using a Base Processing directive to define UBAQ's Update Processing logic
• Using UpdateExt to delete multiple records at once
• Using a Fill Table by Query action to populate the input dataset for a method
• Using error messages from the UpdateExt method
Note The scenario does not cover this, but you can use this Updatable BAQ in an Updatable Dashboard
by creating an Assembly Dashboard and deploying it to a menu. For details on setting up updatable
dashboards, please refer to the Updatable Dashboards section of the Tools User Guide.

In the first two steps of this example, you create an Updatable BAQ using the Business Activity Query Designer.
You will query the Part table. There you will add a calculated field and make it updatable. This field will be used
in the query results grid (most likely on a dashboard) to mark records for deletion. You will another calculated
field to display error messages in the query results if erros occur during the update (delete) process.
Next, you will design the update logic for the query in the BPM Workflow Designer program. You will use a Fill
Table by Query action to populate the dataset for the Part.UpdateExt method with data on records deemed
for deletion. You will modify the RowMod value of the selected records to trigger their deletion.
Then, you will run the UpdateExt method and handle possible errors. You will use an Update Table by Query
action to update the second calculated column in the query results dataset. This column will display error text
for any error that occured during the Update method execution.

Add Query to Select Records for Deletion

In this step, define the query that will be used for selecting parts to delete.

1. Launch Business Activity Query Designer.


Menu Path: System Management > Business Activity Queries > Business Activity Query.

Epicor Kinetic | Classic 153


Delete Multiple Part Records with Updatable BAQ BPM Cookbook

2. In the Main Toolbar, click New.

3. In the Query ID field, type in PartDeletionUBAQ.

4. Add a Description - for example, Allows deleting selected part(s).

5. Select the Shared, All Companies, and Updatable options.

Move on to the Query Builder sheet to design the query.

Design Query

In this step, specify the table to query and define what fields will be displayed.
You will display the required fields - Company and PartNum, as well as PartDescription to help you identify
the data. You will also define two calculated fields:
• DeleteRecord - a bit field that will be used to mark part records to delete.
• ErrorMessage - a character field that will display an error text if an error occurs during the update process.

1. On the Query Builder > Phrase Build sheet, select Erp.Part from the table list and add it to the canvas.

154 Epicor Kinetic | Classic


BPM Cookbook Delete Multiple Part Records with Updatable BAQ

2. Now navigate to the Display Fields > Column Select sheet.

3. Add the following fields to Display Column(s):


Company, PartNum, PartDescription.

4. Then click the Calculator icon to launch Calculated Field SQL Editor.

Epicor Kinetic | Classic 155


Delete Multiple Part Records with Updatable BAQ BPM Cookbook

5. In the Field Name, enter DeleteRecord and press Tab.

6. From the Data Type drop-down, select bit.

7. Modify the default Label to make it read like this: Delete Record.

8. In the Editor field, type in 0 or click the False key to generate this value automatically. This will be the
default value of this field.

9. In the Toolbar, click New to add another calculated field.

10. Add the ErrorMessage field of nvarchar type and adjust the Label to make it readable - for example,
Error Message.

156 Epicor Kinetic | Classic


BPM Cookbook Delete Multiple Part Records with Updatable BAQ

11. In the Editor field, enter two single quotes straight after each other - ''.
By default, the value of this field will an empty string.

12. Save the field settings and close the Editor.


The Display Fields sheet should look like this:

Epicor Kinetic | Classic 157


Delete Multiple Part Records with Updatable BAQ BPM Cookbook

Add Base-Processing Method Directive

In this step, specify the main settings for the directive.

1. Go to the Update > General Properties sheet now.

2. Select the Allow Multiple Row Update option and clear the Allow New Record check box.

3. Mark the Calculated_DeleteRecord field as Updatable.

4. Move on to the Update > Update Processing sheet.

158 Epicor Kinetic | Classic


BPM Cookbook Delete Multiple Part Records with Updatable BAQ

5. Select the Advanced BPM Update Only option,.

6. Click the BPM Directives Configuration button.


The Updatable BAQ Method Directives window displays.

7. In either of the two methods lists - on the List sheet or in the Methods panel, select the Update method.
The method is displayed in the following format: Ice.<CompanyID>/<BAQID>.Update - in this example,
Ice.EPIC06/PartDeletionUBAQ.Update.

8. From the New drop-down in the Main Toolbar, select New Base Processing.
The Base Processing > Details sheet opens for editing.

9. Enter a meaningful Name - for example DeleteMarkedItems.

10. Press Design to open the BPM Workflow Designer.

Design Directive Workflow

In this step, design the BPM workflow for deleting selected records in the database and returning information
on error, if it occurred, into the query results dataset.

1. From the Callers panel, select the Invoke BO Method widget and add it to the canvas.
At this point, do not connect it to any other widgets.

Epicor Kinetic | Classic 159


Delete Multiple Part Records with Updatable BAQ BPM Cookbook

2. Rename it to something appropriate like InvokePartUpdExt and configure the action as follows:

a. Click the specified link.

b. In the Method Search window, select the UpdateExt method of the Part BO and press OK.

c. Click the not configured link.


The Setup Method Parameters window displays.

160 Epicor Kinetic | Classic


BPM Cookbook Delete Multiple Part Records with Updatable BAQ

d. For the ds in-out parameter, create a new variable - in this example, dsItemsToDelete.
This variable will hold the dataset that contains records to delete.

e. Bind the ContinueProcessingOnError parameter to a true expression.

f. Bind the rollBackParentOnChildError parameter to a false expression.

g. Set the ErrorOccurred to [ignore].

h. Create a new variable - dsErrors - for <return value>.

i. Press OK when the setup is complete.

Now populate the input dataset for this BO Method.

3. From the Setters pane, select the Fill Table by Query widget and add it to the workflow.

4. Connect the Start widget to the Fill Table by Query widget, then connect the Fill Table by Query widget
to the InvokePartUpdExt widget.

Epicor Kinetic | Classic 161


Delete Multiple Part Records with Updatable BAQ BPM Cookbook

5. Rename the Fill Table by Query widget to RecordsToDelete and set it up like this:

a. Click the designed link to open the Compose Query program.

b. On the Phrase Build sheet, add the queryResultDataset.Results table to the canvas and select it.

c. Click the New icon to add a new table criteria:

AndOr ( Not Field Operation Filter Value )


Calculated_DeleteRecord = true constant

d. Navigate to the Display Fields sheet and add the table's key fields and SysRowID to display - in this
example:
Part_Company, Part_PartNum, and SysRowID.

162 Epicor Kinetic | Classic


BPM Cookbook Delete Multiple Part Records with Updatable BAQ

e. Click OK when the query setup is complete.

f. Click the specified link.

g. In the Select Table window that displays, choose the dsItemsToDelete.Part table and press OK.

h. Click the not configured link.


The Setup Table Mapping window displays.

Epicor Kinetic | Classic 163


Delete Multiple Part Records with Updatable BAQ BPM Cookbook

i. Press the Bind Automatically button.


Check that all keys (Company and PartNum) and the SysRowID have been bound correctly.

j. Finally, scroll to the bottom and change the binding of the RowMod column to this expression: IceRo
w.ROWSTATE_DELETED.
Note Setting the RowMod to IceRow.ROWSTATE_DELETED is what triggers the deletion. The
SysRowID is used to identify the original line when dealing with error messages.

Now add the mapping of the possible errors back to the queryResultDataset.

6. From the Setters pane, add an Update Table by Query widget to the workflow and give it an appropriate
name such as SetErrors.

164 Epicor Kinetic | Classic


BPM Cookbook Delete Multiple Part Records with Updatable BAQ

7. Join the InvokePartUpdExt widget to the SetErrors widget.

8. Configure the action:

a. Click the designed link to open the Compose Query program.

b. On the Phrase Build sheet, add the dsErrors.BOUpdError table to the canvas.

Epicor Kinetic | Classic 165


Delete Multiple Part Records with Updatable BAQ BPM Cookbook

Click OK in the Specify Table Alias dialog window.

c. On the Display Fields sheet, add the ErrorText and ErrorSysRowID fields to the Display Column(s)
list.

d. Press OK to finish query setup.

e. Change the all rows toggle to changed rows.

f. Click the specified link.

g. In the Select Table window, choose the queryResultDataset.Results table and click OK.

h. Click the not configured link.


The Setup Table Mapping window displays.

166 Epicor Kinetic | Classic


BPM Cookbook Delete Multiple Part Records with Updatable BAQ

i. In the Relations section, click the New icon to add a new relation:

queryResultDatset.Results table Query


SysRowID dsErrors_BOUpdError_ErrorSysRowID

Note This mapping is mapping the ErrorSysRowID back to the original SysRowID.

j. In the Columns grid, bind the Calculated_ErrorMessage field to the dsErrors_BOUpdError_ErrorText


field and press OK.

9. Review and save the workflow.

Epicor Kinetic | Classic 167


Delete Multiple Part Records with Updatable BAQ BPM Cookbook

10. Close the BPM Workflow Designer.

11. Enable and save the directive.

12. Close the Updatable BAQ Method Directives window.

13. Save the PartDeletionUBAQ.

168 Epicor Kinetic | Classic


BPM Cookbook Delete Multiple Part Records with Updatable BAQ

Keep the Business Activity Query Designer open and move to testing the query.

Test Directive

In this step, test your updatable query.

1. Launch Part Maintenance.


Note This menu can be accessed from multiple modules - for example, Production Management
> Engineering > Setup > Part.

2. From the New drop-down in the Main Toolbar, select New Part.

3. For the Part ID, type in 00000Test.

4. Add a Description - for example, Test Part.

5. Keep all the default properties and save the part.

6. Now go back to the Business Activity Query Designer and open the Analyze sheet.

Epicor Kinetic | Classic 169


Delete Multiple Part Records with Updatable BAQ BPM Cookbook

7. Press the Get List button.


The Query Results display in the grid. Note the new 00000Test part in the top row.

8. Double-click on the row containing the new part.


The Fields dialog window pops up.

9. Select the Delete Record check box and press OK.

Note the line is now highlighted in yellow.

10. Double-click on another part that you know has transactions against it (so it will not allow deletion) - in this
example, 00C1 (Component C1).

11. Again, select the Delete Record check box and press OK.
You now have two lines to update highlighted in yellow.

170 Epicor Kinetic | Classic


BPM Cookbook Delete Multiple Part Records with Updatable BAQ

12. Press Update.


The lines are no longer highlighted. The 00C1 part line now contains an error message:

13. Press Get List again.


Note the 00000Test part has disappeared from the list while 00C1 remains in the results:

Epicor Kinetic | Classic 171


Delete Multiple Part Records with Updatable BAQ BPM Cookbook

172 Epicor Kinetic | Classic


Additional information is available at the Education and
Documentation areas of the EPICweb Customer Portal. To access
this site, you need a Site ID and an EPICweb account. To create an
account, go to http://support.epicor.com.

You might also like