Apex Designer Documentation
What's New
Getting Started
Projects
Business Objects
Processes
User Interfaces
App Behaviors
Files
Dependencies
Project Settings
Libraries
Patterns and Best Practices
App Showcase

Add A Service Task To The Onboard Supplier Process

Add automation to your process

Blank Profile Image
Written by Jim Volpe
Updated 2 days ago
5 min read

The two previous lessons focused mostly on user tasks and the user interfaces to allow people to interact with the process. In this lesson, you will add automation to your process by including a system activity. 

The Onboard Supplier Process currently carries some information about our new supplier. The supplier representative gives some additional information in their step in the process, but they should not have the access rights to create the supplier record in our system. Therefore, we will take this action in a new system service.

Link Supplier to the Process Variable

  1. Navigate to the Onboard Supplier business object using the Business Objects button from the ribbon category
  2. Select the Onboard Supplier business object.
  3. Add a relationship by typing part of the word "supplier", then scroll down to select "belongs to Supplier":
    Add "belongs to Supplier" relationship
  4. Note the relationships in the dialog, although no changes are necessary:
    Business Object Relationship dialog

Add the Create Supplier System Service

  1. Navigate to Processes using the button on the ribbon share 
  2. Select the Onboard Supplier process.
  3. To add the new activity in the diagram, first select the Complete Application activity:
    Select the Complete Application activity
  4. Click the Create Service Task button to the right and below the activity:
    Click the Create Service Task button
  5. Type the name Create Supplier in the new activity:
    Rename Activity to Create Supplier
  6. Click on the end event, and with the mouse still down, drag it to the right of Create Supplier:
    Move end event
  7. Click on the wire that leads from Complete Application to the end event:
    Select the wire leading from Complete Application to the end event
  8. The tiny blue circles on the wire are now editable. Drag the start endpoint of the wire, attaching it to the Create Supplier activity:
    Link End event to the Create Supplier activity

Implement the System Service

  1. Select the Create Supplier activity.
  2. Click the Open Service Task Behavior button:
    Open Service Task Behavior button
  3. Notice that some things are added automatically, including the debug lines in the Implementation. These can be used for troubleshooting. More on that can be found in Debugging Behaviors.
  4. On the right, click into the Add dependency field and type "supp":
    Add dependency Supplier business object
  5. Select the Supplier business object. Adding it as a dependency allows you to reference that business object within the behavior.
  6. Before continuing with the behavior, expand the Supplier dependency by selecting it.
  7. Use the View Business Object button to navigate to the Supplier business object:
    Navigate to the Supplier business object from dependencies
  8. Although we added the Employee Identification Number to the Onboard Supplier business object, we also need to add it here. Add the property:
    Add Employee Identification Number to the Onboard Supplier business object
  9. Navigate back to the behavior using the Recent Items button history in the toolbar and selecting it:
    Navigate to the behavior OnboardSupplier.createSupplier
  10. In the Implementation of your behavior, include the logic to initialize the supplier variable, add data from the onboarding process, save the data and link the supplier to the onboarding supplier (for more about working with data, see Managing Data In A Business Object Behavior) :
    debug('onboardSupplier %j', onboardSupplier);
    debug('externalTask %j', externalTask);
    
    // Initialize the supplier variable, using the Supplier business object
    let supplier = new Supplier();
    
    // Set the values from the process variable
    supplier.name = onboardSupplier.supplierName;
    supplier.employerIdentificationNumber = onboardSupplier.employerIdentificationNumber;
    
    // Add a random number as the code
    supplier.code = Math.floor(Math.random() * 10000);
    
    // Save the data, creating the new supplier in the database
    await supplier.save();
    
    // Write debug to the log, showing the full object after it has been saved
    debug('supplier %j', supplier);
    
    // To link the supplier to onboardSupplier, add the supplierId as the id of the supplier
    onboardSupplier.supplierId = supplier.id;
    
    // Write debug to the log before saving
    debug('onboardSupplier %j', onboardSupplier);
    
    // Save the change to the database
    await onboardSupplier.save();
  11. Since there were several changes, generate the app using the Generate App button autorenew in the upper right.

Running the Service

In the previous lesson, the service task did not exist in that version of the process. If we tried to finish the process instance that we started in that lesson, it would not run your new service task.

When you generated the app in the step above, a new version of the process was deployed that included the additional service task. Although it is possible to "migrate" the instance from the older process version to the new one, we will avoid that for now. Instead, you can start a new instance that will use the new version of the process:

  1. In the running app, navigate to the Suppliers page.
  2. Click the Onboard Supplier button Add a Process button to start a new process instance.
  3. Populate the fields for the supplier and submit the task to complete it:
    Initiate onboarding UI 
  4. Back on the My Tasks page, click the Complete Application task for the new supplier (be sure to pick the most recently created task).
  5. Before completing the task, click the Show Process Diagram button share to see that the new activity is now shown:
    Complete application UI
  6. Add an Employer Identification Number and click the Submit button:
    Complete application UI
  7. On the Suppliers page, does your supplier now show on the list? If so, congratulations, you have built and completed your process!
    Suppliers page

In this lesson you linked the Supplier business object with the Onboard Supplier process business object, added a system activity, then detailed the implementation of the system activity. Finally, you completed the last two tasks within your process and viewed the results.

 

Powered by Apex Designer
Terms of ServicePrivacy Policy
© 2017-2022 Apex Process Consultants