Help ELMA BPM Platform
×
Menu

Example of Using Custom Activity


Often in a process you need to calculate a date according to the business calendar. To implement this function without a skilled programmer, do the following: create a custom activity titled "Add N Business Days" on the Scripts tab of ELMA Designer, in the Custom Activities section (Fig. 1).
Fig. 1. Custom Activity page. Display Settings tab.
Go to the Parameters tab and specify two input properties (Start Date of the Date/Time type; and Day Interval of the Integer type) and one output property (Expected Date of the Date/Time type).
Fig. 2. Custom Activity page. Parameters tab.
Go to the Scripts tab and make calculations of the date according to the business calendar:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Parameters = EleWise.ELMA.Workflow.Models.Parameters.CA_AddNBusinessDays;
namespace EleWise.ELMA.Model.Scripts
{
    ///
    /// "Add N working Days" Custom Activity script module
    ///
    //Attention! For the program to function, do not change the class name
    public class CA_AddNWorkingDays_Scripts
    {
        //Attention! The class must contain the Execute method with this signature
        public void Execute(Parameters parameters)
        {
               var calendar = Locator.GetServiceNotNull<IProductionCalendarService&rt();
               parameters.ExpectedDate = calendar.EvalTargetTime(parameters.StartDate.Value,
                                                            TimeSpan.FromDays((double)parameters.DayInterval));
        }
    }
}
Fig. 3. Custom Activity page. Scripts tab.
The custom activity is ready. Publish it and check if it became available in the Plug-Ins section of the side panel of the process page (Fig. 4).
Fig. 4. The "Add N Business Days" custom activity in the "Plug-Ins" section of the process graphic model.
To add a custom activity to the graphic model, find it in the side panel and place it in the process diagram. Consider a simple process of issuing an invoice (Fig. 5).
Fig. 5. "Issue Invoice" process map.
Employee of the Sales Department issues the invoice, specifies the invoice number, date and contractor. Then the accountant receives payment and confirms it. The invoice is valid for 3 days. If it is not paid on time, the Sales Department employee must issue it again.
Further down below you can see the settings of the "Issue the invoice" task (Fig. 6), input/output attributes of the "Add N Business Days" custom activity (Fig .7) and settings of escalation by timer of the "Confirm payment" activity (Fig. 8).
Fig. 6. "Issue the invoice" task settings.
Fig. 7. Input/output attributes of the "Add N Business Days" custom activity.
Fig. 8. Escalation settings of the "Confirm payment" activity.

Copyright © 2006–2019 ELMA