logo

Creating a portlet for a component in Designer

This article provides an example of creating a portlet for the Contract Management process package. The component includes two processes: "Create Document by Template" and "Approve Contract", whose instances will be displayed in a portlet block.

The block has the following columns:

  1. Instance name (Process Instance type);
  2. Initiator (User type);
  3. Start date (Date/Time type);

The portlet has settings: a user can select on which process information should be displayed.

Portlets can be created on the Interface tab of ELMA Designer. To create a portlet right-click on the Portlets folder and select Create Portlet or click Add - Portlet in the toolbar. After that, add all the required context variables, settings, configure the display of your portlet using the form builder and implement the portlet logic in the controller.

Fig. 1. Creating a portlet in Designer

Display example

Fig. 2. Portlet with a block displaying active process instances

Fig. 3. Portlet settings

Example of portlet implementation

In the Interface section, a new portlet was added with a block containing the following fields:

  1. Instance name;
  2. Initiator;
  3. Start date;

Fig. 4. Portlet context

After adding a context, configure the portlet view on the View tab. It is done in the form builder, which allows quickly and conveniently create a portlet form.

Fig. 5. Portlet view

On the Portlet Settings tab, a variable of the Process Header type with the List link type was added.

Fig. 6. Portlet settings

Controller code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EleWise.ELMA.Workflow.Models;
using EleWise.ELMA.Model.Managers;
using EleWise.ELMA.UI.Controllers;
using EleWise.ELMA.UI.Models;
using EleWise.ELMA.UI.Results;
using EleWise.ELMA.API;
 
namespace EleWise.ELMA.UI.Portlets
{
 
  /// <summary>
  /// "Process statuses" portlet controller
  /// </summary>
  public partial class StatusyPoProcessamController : PortletController<StatusyPoProcessam.Content, StatusyPoProcessam.Personalization, StatusyPoProcessam.Settings>
  {
 
    /// <summary>
    /// Load the portlet content
    /// </summary>
    /// <param name="portlet">Portlet model</param>
    public override void Content_Load(PortletContentLoadViewModel<StatusyPoProcessam.Content, StatusyPoProcessam.Personalization> portlet)
    {
      List<WorkflowInstanceStatus> wkflinststatuses = new List<WorkflowInstanceStatus>();
      wkflinststatuses.Add(PublicAPI.Enums.Workflow.WorkflowInstanceStatus.Running); //Active status
 
      var currUser = PublicAPI.Portal.Security.User.GetCurrentUser();
 
      foreach (var process in portlet.Settings.ProcessHeader)
      {
        var fl = PublicAPI.Processes.WorkflowInstance.Filter().ProcessHeader(process).Statuses(wkflinststatuses).Find(); // A process selected in the settings with the Active status
        foreach (var tmpProcess in fl)
        {
          if (tmpProcess.Members.Any(m => m.User == currUser) || tmpProcess.Responsible == currUser) //Only process participants or the responsible user
          {
 
            var block = EntityManager<StatusyPoProcessam.Content_ContractDocumentApproval>.Create();
            block.WorkflowInstance = tmpProcess;
            block.Initiator = tmpProcess.Initiator;
            block.StartDate = tmpProcess.StartDate; 
            portlet.Context.ContractDocumentApproval.Add(block);
          }
        }
      }
    }
  }
 
}