Complex Process Flow and Event Handler Example

Now that we have walked through the basics of creating a process flow and attaching it to an event within the application, we are ready to take on something a bit more complex. For this example, it is assumed that the Process Components and Event Definitions records delivered with the standard application exist, and that the following services have been added to the user's application:

  • Process Categories
  • Process Flows
  • Event Handlers
  • Orders
  • Persons
  • Products

The Aptify user must also have a linked Employees record.

This topic covers the following sub-topics related to setting up a complex process flow:

Business Case and Designing the Complex Process Flow

In the first step in the Complex Process Flow tutorial, an organization decides to send promotional literature to every new contact and notify the Sales department so that they may follow up once the literature has been received. The promotional literature should be sent, and the Sales department notified, however, only if the individual is not associated with a company.

Outlining the Process Flow

The first step in any process flow configuration is to outline the process.

How Many Steps?

Look closely at the business case. When new Persons records are created within Aptify, we must first determine whether that person is associated with a company. This may be done simply by noting whether the Company field on the Persons form is populated.

The next step in the process is to send the product literature (but only if the person is not associated with a company). This is implemented in Aptify by creating a new Orders record and adding an Order Line for the literature. This constitutes two steps.

The final step in the process is to send an email notification to the Sales department. This is similar to the XY Send email process flow built earlier in this tutorial and constitutes a single step in the process flow.

Putting these steps in logical order, the process flow to build is defined as follows:

  • Step 1: Determine whether to send the literature.
  • Step 2: Create an Orders record for the Person.
  • Step 3: Create an Order Line for the literature and save the order.
  • Step 4: Send an email notification to the Sales department.

Does the Functionality Already Exist?

Let's look at the four steps:

  • Step 1: Determine whether to send the literature — Aptify provides a Value Tester component that can be used to branch logic based on the value of a particular field. In this case, you could use the Value Tester to check the value of the CompanyID field. However, this tutorial uses a rule-based step to illustrate how this type of step is used.
  • Step 2: Create an Orders record — A Create Orders Record process component is delivered with the standard Aptify application. This step may take advantage of this existing functionality.
  • Step 3: Create an Order Lines record — A Create Order Lines Record process component is delivered with the standard Aptify application. This step may take advantage of this existing functionality.
  • Step 4: Send an email notification — Making use of a previously defined process flow (the XY Send email process flow created in the first part of this tutorial) reduces the amount of work necessary. This is done by basing the step on a Sub-Process.

What Data Will the Process Flow Use?

Setting up the XY Send email process flow earlier in the tutorial generated the following list of required data elements:

  • The recipient of the message
  • The sender of the message
  • The subject of the message
  • The text of the message
  • The format of the email
  • The email addresses for the CC list
  • The email addresses for the BCC list

Additional Data

To satisfy this business case, additional data elements are necessary. Creating an Orders record within Aptify requires the following information:

  • The Ship-To person and address
  • The Bill-To person and address
  • The product to order

Completing the Outline

Now that the number and sequence of the process flow steps, data required, and data returned have been determined, the process flow may be set up in Aptify.


Creating the Complex Process Flow Literature Product

In this step of the Complex Process Flow tutorial, because the business case developed in this example requires Orders records to be created, the product to be ordered must be determined. For the purposes of this tutorial, a new Products record must be created.

  1. Open a new record from the Products service.
  2. Enter XY Product Literature in the Name field, where XY are your initials.
  3. Continue setting up the product.
    • Select the Allow Free option on the product's Prices > Settings tab. In this example, the literature is sent free of charge.
    • For simplicity, it is recommended that no inventory be required.
    • For more information on setting up products, see Using Product Setup and Maintenance.

Write down the ID of the product once it is saved. This ID is used in configuring the input properties of the Event Handler later in this example.


Creating the Complex Process Flow

In this step of the Complex Process Flow tutorial, you perform the procedures necessary to create a complex process flow, as described in the sections below:

Creating the Process Flows Record

follow these steps to create the Process Flows record:

  1. Open a new record from the Process Flows service.
  2. In the Name field, enter XY Send Product Literature where XY are your initials. If desired, enter a description.
  3. Enter email Notifications in the Category field. This links the record to the Process Flow Categories record created in the first example of this tutorial.
  4. Save the record.

Defining the Input Properties

The list of necessary input properties is based on the list of data used by the process flow generated during the Outlining process. This list is a combination of all data required by all steps within the process flow.

A few additional Input Properties have been added to this list, beyond what was deemed necessary during the Outlining process. These were determined by reviewing the Input Properties tab of the Create Order process components and the Input Properties tab of the XY Send email process flow. This underscores the importance of understanding how the components are configured within the application.

 

Enter the following rows into the Input Properties tab. When all rows are entered, save the Process Flows record.

Name

Type

Default Value

Required

Value List Type

To

String

 

Yes

None

Subject

String

 

Yes

None

TextBody

String

 

Yes

None

PersonID

Integer

 

Yes

None

EmployeeID

Integer

 

Yes

None

ProductID

Integer

 

Yes

None

Defining the Result Codes

Create the following result codes for the Process Flows record on the Result Codes tab and save the record:

Code

Description

Success

EMAIL_SENT

Order created and email sent.

Yes

AFFILIATED

Person affiliated with company.

Yes

FAILED

Failure encountered.

No

Defining the Process Flow Steps

This section describes how to create the four steps in this process flow:

Step 1: Determining Whether to Send the Product Literature

Follow these steps to create the first step (which is rule-based):

  1. Click the Design tab.
  2. Select the Insert Rule Step button in the toolbar.
  3. Move the cursor to the design area and click the mouse button to drop the rule step in the selected location.
    • A new step appears in the Design area. The step's details load in the Properties area on the right-side of the Process Flows record.
    • Resize the form as necessary so you can read all of the fields in the Properties area.
  4. Within the step's Properties area, Enter XY Determine Company Link in the Name field. Enter a description if desired on the Description tab.
  5. Click the Rule tab.
    • Because this is a rule-based step, either SQL or VBScript may be used to extract the correct information. The functionality of this step is to determine whether to send the product literature by finding out whether or not the person is associated with a company. SQL provides the best method of determining this information.
  6. Select SQL in the Rule Type list and enter the following into the text box:

    Select ID = 
    CASE
    WHEN CompanyID IS NULL 
    THEN 'Unlinked'
    ELSE 'Linked'
    END
    FROM APTIFY.dbo.vwPersons WHERE ID=<%PersonID%>


    SQL Rule Step

  7. Save the process flow.

Step 2: Creating the Orders Record

Once the rule step determines that the product literature should be sent, the next step is to create an order for that literature. This step makes use of the existing Create Orders Record process component.

  1. Select the Insert Component Step button in the toolbar.
  2. Move the cursor to the design area so it is to the right of the rule-based step. Click the mouse button to drop the component step in the selected location.
    • A new step appears in the Design area. The step's details load in the Properties area on the right-side of the Process Flows record.

    Add Component Step

  3. In the step's Properties area, enter XY Create Literature Order in the Name field. Enter a description on the Description tab, if desired.
  4. Under the Properties tab, select the drown arrow to the right of the Component field to display the available component categories.
  5. Expand the (Entity Operations) > Orders category.

    Select Component
  6. Select the Create Orders Record component from the list.
    • The component's input properties automatically flow down to the step's Properties tab.
  7. Populate the rows on the Properties tab as specified below. Not all rows on the tab are configured, as not all of the input properties are required or necessary for the purposes of this example. The figure provides an illustration of how some of the inputs from the table below should appear in the Process Flows record.

    Input Property

    Source Type

    Source

    Notes

    SaveRecord

    Static Value

    No

    For this process flow, you do not want to save the Orders record until after you have added the Order Line in Step 3, so set this to No.

    ID

    Static Value

    -1

    The ID will be assigned automatically when the Order is saved. Set this to -1 as a placeholder since this is a required field.

    OrderDate

    Formula

    GetDate()

    Change the Source Type from Static Value to Formula since GetDate() is a SQL Expression. The order will use the current date and time as the Order Date.

    ShipToID

    Context Object

    PersonID

     

    ShipToCountryCodeID

    Static Value
    See Notes column

    222
    See Notes column

    If the Person does not have an address, then you need to specify the Country Code ID to save the record. This tutorial sets this property to minimize user error. You can use a different Source Type as needed.

    BillToID

    Context Object

    PersonID

     

    BillToCountryCodeID

    Static Value
    See Notes column

    222
    See Notes column

    If the Person does not have an address, then you need to specify the Country Code ID to save the record. This tutorial sets this property to minimize user error. You can use a different Source Type as needed.

    EmployeeID

    Context Object

    EmployeeID

     

    OrganizationID

    Static Value

    1

    Enter the ID of an Organization's record. For the sake of simplicity, this tutorial sets it to 1 but you could use another source type as necessary.

    PayTypeID

    Static Value

    1

    Set the pay type to Purchase Order since there will be no charge for this literature order.

    PONumber

    Static Value

    N/A

     

    OrderLevelID

    Static Value

    1

    Enter the ID of the application OrderLevel record. For the sake of simplicity, this tutorial sets it to 1 but you could use another source type as necessary.

     

    Create Order Record Inputs

  8. Save the record.
  9. Click the Output Map tab.
  10. Configure the following settings for the GEObject output property so the Orders GE object can be passed to the Create OrderLines Record component in the next step of the Process Flow:
    • Destination Type: Context Object
    • Destination: GEObject

      Step's Output Map
  11. Save the record.

Step 3: Creating the Order Lines Record

After adding the Create Orders Record component, you need to add the Create Order Lines component that adds the order line for the literature to the order.

  1. Select the Insert Component Step button in the toolbar.
  2. Move the cursor to the design area so it is below the Create Orders Record step. Click the mouse button to drop the component step in the selected location.
    • A new step appears in the Design area. The step's details load in the Properties area on the right-side of the Process Flows record.
  3. In the step's Properties area, enter XY Create Literature Order Line in the Name field. Enter a description on the Description tab, if desired.
  4. Under the Properties tab, select the drown arrow to the right of the Component field to display the available component categories.
  5. Expand the (Entity Operations) > OrderLines category.
  6. Select the Create OrderLines Record component from the list.
    • The component's input properties automatically flow down to the step's Properties tab.
  7. Populate the rows on the Properties tab as specified below. Not all rows on the tab are configured, as not all of the input properties are required or necessary for the purposes of this example.

    Input Property

    Source Type

    Source

    Notes

    SaveRecord

    Static Value

    Yes

    After adding the Order Line, this will save the OrderLines sub-type record and the Orders record.

    ParentGEObject

    Context Object

    GEObject

    The GEObject option will not appear in the Source drop-down list since it is not specified as an Input Property on the Process Flow. However, you can manually enter this value in the Source field.

    ProductID

    Context Object

    ProductID

     

    Quantity

    Static Value

    1

    Send 1 unit of the product.

    Price

    Static Value

    0

    The product literature is sent free of charge in this example.

  8. Save the record.

Step 4: Notifying the Sales department

The final step in the process sends an email notification to the Sales department. This step may make use of an existing process flow.

  1. Select the Insert Sub-Process Step button in the toolbar.
  2. Move the cursor to the design area so it is to right of the Create OrderLines Record step. Click the mouse button to drop the step in the selected location.
    • A new step appears in the Design area. The step's details load in the Properties area on the right-side of the Process Flows record.
  3. In the step's Properties area, enter XY Send Email SubProcess Step in the Name field. Enter a description on the Description tab, if desired.
  4. Select the XY Send email process flow from the Sub-Process drop-down list.
    • The process flow's input properties appear in the Properties area.
  5. Set the value of Source on each input map to Context Object.
  6. In the Source field, select from the list the corresponding input property you previously specified on the process flow's Input Properties tab.
  7. Save the record.

Linking the Process Flow Steps

Once the steps are created, they must be linked together to form the complete process flow. Perform the steps in the following sections:

Linking Step 1 to Step 2

Follow this procedure to link step 1 to step 2:

  1. Click the Insert Result Code Link icon in the toolbar.
  2. Place the cursor over one of the handles of step 1's box until it becomes a target symbol. Click the mouse button.

    Adding a Link Between Steps
  3. Drag the cursor over a handle of step 2's box. Click the mouse button.
    • The Create New Result Code dialog appears.
  4. Enter Unlinked in the Result Code field. Leave Is Success selected.

    Specify Result Code
  5. Click OK to close the dialog.
    • A link labeled Unlinked is added between steps 1 and 2 in the diagram.
  6. Select Step 1 in the diagram to load its properties.
  7. Click the Action Map tab.
    • The Unlinked action already appears on this tab.
  8. Click the New Map button to open the Create New Result Code dialog.
  9. Enter Linked in the Result Code field and leave Is Success selected. Click OK to save and close the dialog.
    • A Linked action appears in the Action Map.
  10. For the Linked action, select End Process as the Action and enter AFFILIATED in the Process Flow Result Code field.

    Specify Action Map Properties
  11. Save the record.

Linking Step 2 to Step 3

Follow this procedure to link step 2 to step 3:

  1. Click the Insert Result Code Link icon in the toolbar.
  2. Place the cursor over one of the handles of step 2's box until it becomes a target symbol. Click the mouse button.
  3. Drag the cursor over a handle of step 3's box. Click the mouse button.
    • The Create New Result Code dialog appears.
  4. Select Success as the result code and click OK.
  5. Select Step 2 in the diagram to load its properties.
  6. Click the Action Map tab.
  7. For the Failed action, select End Process as the Action and enter FAILED in the Process Flow Result Code field.
  8. Save the record.

Linking Step 3 to Step 4

Follow this procedure to link step 3 to step 4:

  1. Click the Insert Result Code Link icon in the toolbar.
  2. Place the cursor over one of the handles of step 3's box until it becomes a target symbol. Click the mouse button.
  3. Drag the cursor over a handle of step 4's box. Click the mouse button.
    • The Create New Result Code dialog appears.
  4. Select Success as the result code and click OK.
  5. Select Step 3 in the diagram to load its properties.
  6. Click the Action Map tab.
  7. For the Failed action, select End Process as the Action and enter FAILED in the Process Flow Result Code field.
  8. Save the record.

Ending the Process Flow

For the last step in the process flow, you need to mark all of its actions as End Process. Follow this procedure:

  1. Select Step 4 in the diagram to load its properties.
  2. Click the Action Map tab.
  3. For both actions, select End Process as the Action.
  4. For the SUCCESS action, enter EMAIL_SENT in the Process Flow Result Code field.
  5. For the FAILED action, enter FAILED in the Process Flow Result Code field.
  6. Save the record.

The following figure illustrates the process flow when all steps are linked.

Linked -Process Flow Steps

At this point, you can use the Process Flow Debugger tool to test your process flow. See Using the Process Flow Debugger for details.


Linking the Complex Process Flow to an Entity

In this step of the Complex Process Flow tutorial, Event Handlers are used to link process flows to entities or applications. As discussed in the first example in this tutorial, it is important to determine the appropriate event to use for any configuration of a service's functionality.

For the business case used in this part of the tutorial, we know that whenever a new Persons record is created for a person who is not associated with a company, a new Orders record is created and an email is sent. Once again, we make the assumption that this functionality should run only after the record has been saved in the database. Based on this assumption, the process flow must be linked to the AfterRecordCreated event on the Persons entity.

Perform the following steps to set up the event handler:

  1. Select the Process Pipeline Administration application to load its dashboard.
  2. In the Event Handler Management area, select Entities as the Event Scope.
  3. Enter Persons in the Entity field. Upon tabbing out of the field, the grid below displays with a list of all other Event Handlers attached to the Persons entity, if any.

    Event Handler Management Dashboard
  4. Click Add Event. The Event Handler form now displays.
  5. In the Event field, enter AfterRecordCreated.
  6. In the Process Flow field, enter the XY Send Product Literature process flow.
    • Once the Process Flow field is filled, the Input Map tab populates with a list of records inherited from the input properties defined on the process flow selected.
  7. Follow the information listed below to configure each Input Map.
    • Each row may be configured directly in the grid, or by double-clicking on the row or clicking the ellipsis (...) button in the Source field to display an Edit Mapping dialog box.

      Input Property

      Source Type

      Source

      To

      Static Value

      <<your email address>>

      Subject

      Static Value

      Product Literature Sent

      TextBody

      Static Value

      Product literature has been sent to <%FirstName%> <%LastName%>. Please follow up once literature has been received.

      PersonID

      Entity Field

      ID

      EmployeeID

      Entity Field

      MainAccountManager[For the sake of simplicity, this example uses the Person's Account Manager as the Employee]

      ProductList

      Static Value

      <<ID of the product you created>>


      Configure Event Handler

  8. Click OK to save the record.
  9. Close the Aptify application and restart before continuing.

Testing the Complex Process Flow Event

In the final step of the Complex Process Flow tutorial, the process flow has been created and linked to the Persons entity. All that remains now is to test the functionality. To do this:

  1. Open a new record from the Persons service.
  2. Enter first and last name, putting XY at the beginning of the last name entered, where XY are your initials.
  3. Save the record.
  4. Check your email for the notification that the product literature was sent, including the name of the person whose record you just created. Open this Persons record in Aptify and click on the Orders tab to validate that an order was created. Open the Orders record to validate that the order was placed for the correct product.
    • Depending on the email system used, you may receive a message stating that an outside source is attempting to send an email. Click the OK button to allow this to occur.

Next, make sure that the filter created in the rule-based step is functioning correctly. We know that the order was created automatically when the Persons record created is not associated with a company. The next step is to make sure that the product literature is not sent when a person is associated with a company.

  1. Open a new record from the Persons service.
  2. Enter first and last name, putting XY at the beginning of the last name entered, where XY are your initials.
  3. Enter or select a company.
  4. Save the record.
  5. Check to see if an email notification was sent.
  6. Create a view in the Orders service for all orders made by the Persons record created in this test. If the process flow functioned correctly, the view does not include any records.

Cleaning Up

Unless you make the Event Handler inactive, you will continue to receive email messages every time anyone creates a new Persons record without a linked company in the system.

  1. Open the Event Handler created in this example.
  2. Clear the Active option.
  3. Click OK to save the record, then exit the Event Handler Management form.

Close Aptify and reopen the application before performing any more processing within the system.

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.