logo

Getting the list of decision-based tasks in a script

You can access all the decision-based tasks of a certain document using the script below.

Script without PublicAPI

Use the following namespaces:
using EleWise.ELMA.Documents.Models;
using EleWise.ELMA.Documents.Managers; 
using EleWise.ELMA.Documents.Models.Tasks;
using EleWise.ELMA.Model.Common;
using EleWise.ELMA.Model.Managers;
using EleWise.ELMA.Tasks.Models;

The script uses the following context variables: 

context.Document1 - variable that has a certain document type as a type
context.Executor1 - variable of the User type

Script text:

//the Document1 context variable stores the document, tasks on which will be obtained.
//Write the document decision to the resolution variable:
         var resolution = context.Document1.Resolution.First();        
  // find all the tasks based on the decision:       
         var res_task = TaskBaseExtensionManager.Instance.GetTaskForResolution(resolution).ToList();
  //if you need to perform operations with each task (e.g. write the executor to the context variable):
         res_task.ForEach(rt =>{
                           context.Executor1 = (User)rt.Executor;
                           });
 
 
Creating a similar script with PublicAPI
Documentation on PublicAPI is available here

Context variables:

context.Document1 - variable that has a certain document type as a type
context.Executor1 - variable of the User type

Namespace:

using EleWise.ELMA.API;

Script text:

//the Document1 context variable stores the document, tasks on which will be obtained.
//Write the document decision to the resolution variable:
var res_task = PublicAPI.Docflow.Tasks.GetTaskByResolution(context.Document1.Resolution.First()).ToList();
//if you need to perform operations with each task (e.g. write the executor to the context variable):
res_task.ForEach(rt =>{
                    context.Executor1 = (User)rt.Executor;
                        });