logo

Making several decisions on one documents

Several decisions on a document

The article describes:

  1. Creating several decisions on one document.
  2. Creating tasks based on each decision.
  3. Changing the form of the standard consideration tab of a certain document type for displaying tasks based on each decision. 

Creating decisions

At the moment, there can only be one Decision on Document object in the system. To add several decisions on a document, you can use a condition that the Decision object contains a list of decision results.

Script for creating several decision results

The script checks whether there is a decision object, if there is not, a decision with a result is created, if the object is already created, only the result is added.

var resolution = ((IDocumentExt)context.Doc).Resolution.FirstOrDefault();
if (resolution == null)
{
// Create a new decision
 
resolution = InterfaceActivator.Create<Resolution>();
resolution.Author = context.DecisionAuthor; // Decision author
resolution.Date = context.DecisionDate; // Decision date
resolution.Document = context.Doc; // Document, decision on which was made
resolution.Status = ResolutionStatus.Complete; // Decision status
}
// Create a result
var addResult = InterfaceActivator.Create<ResolutionResult>();
addResult.CreationDate = context.DecisionDate; // Decision date
addResult.Text = context.DecisionText; // Decision text
 
addResult.User = context.DecisionAuthor; // Decision author
addResult.Resolution = (Resolution)resolution; // Decision
resolution.Results.Add(addResult); // Add a result
resolution.Save(); // Save the result

Namespaces

using EleWise.ELMA.Documents.Models;
using EleWise.ELMA.Services;
 
 
Creating a similar script with PublicAPI
Documentation on PublicAPI is available here
var resolution = ((IDocumentExt)context.Doc).Resolution.FirstOrDefault();
if (resolution == null)
{
    resolution = PublicAPI.Docflow.Objects.Resolution.Create();
    resolution.Author = context.DecisionAuthor; // Decision author
    resolution.Date = context.DecisionDate; // Decision date
    resolution.Document = context.Doc; // Document, on which the decision was made
    resolution.Status = ResolutionStatus.Complete; // Decision status
}
// Create a result
var addResult = PublicAPI.Docflow.Objects.ResolutionResult.Create();
addResult.CreationDate = context.DecisionDate; // Decision date
addResult.Text = context.DecisionText; // Decision text
 
addResult.User = context.DecisionAuthor; // Decision author
addResult.Resolution = (Resolution)resolution; // Decision
resolution.Results.Add(addResult); // Add the result
resolution.Save(); // Save the result

Create tasks

To display tasks on the Consideration tab, add a boolean attribute the Task object, e.g. DecisionV. When creating a task, it will get the true value.

The script assigns executors with decision-based tasks with the document attached.

Task creation script

foreach (var user in context.Executors)
{
 
// Create a task
var task = InterfaceActivator.Create<Task>();
task.Subject = context.Name; // Task subject
task.Executor = user; // Task executor
task.StartDate = context.DecisionDate; // Decision date
task.EndDate = context.ExecutionDate; // Due date
task.Description = item.OrderText; // Task description
task.DecisionV = true; // Variable created in the Task object
task.CreationAuthor = context.DecisionAuthor; // Task author
// Added attachments
var newDocAtt = InterfaceActivator.Create<DocumentAttachment>();
newDocAtt.Document = context. Doc; // Attached document
newDocAtt.CreationAuthor = task.CreationAuthor; // Attachment author
newDocAtt.CreationDate = DateTime.Now; //Attachment creation date
newDocAtt.Save(); // Save the attachment
task.DocumentAttachments.Add(newDocAtt); // Attachments added to the task
task.Save(); // Save the task
}
 

Namespaces

using EleWise.ELMA.Services;
using EleWise.ELMA.Documents.Models;
 
Creating a similar script with PublicAPI
Documentation on PublicAPI is available here
foreach (var user in context.Executors)
{
    // Create a task
    var task = PublicAPI.Portal.TaskBase.Task.Create();
    task.Subject = context.Name; // Task subject
    task.Executor = user; // Task executor
    task.StartDate = context.DecisionDate; // Decision date
    task.EndDate = context.ExecutionDate; // Due date
    task.Description = item.OrderText; // Task description
    task.DecisionV = true; // Variable created in the Task object
    task.CreationAuthor = context.DecisionAuthor; // Task author
    // Added attachments
    var newDocAtt = PublicAPI.Docflow.Objects.DocumentAttachment.Create(context.Doc, task.CreationAuthor);
    task.DocumentAttachments.Add(newDocAtt); // Attachments added to the task
    task.Save(); // Save the task
}
 

Changing the page display

For convenient display of information on document decisions and tasks based on each decision, make changes to the standard Consideration tab in a certain document type. After making the changes, the page will look like this:

 

To change the standard form, replace/add the following configuration files:

\Web\Modules\EleWise.ELMA.Documents.Docflow.Web\Views\Resolution\Info.cshtml

\Web\Modules\EleWise.ELMA.Documents.Docflow.Web\Views\Resolution\Results.cshtml

\Web\Modules\EleWise.ELMA.Documents.Docflow.Web\Views\Resolution\ResultsContent.cshtml

\Web\Modules\EleWise.ELMA.Documents.Docflow.Web\Views\Resolution\ResultsContentExt.cshtml

\Web\Modules\EleWise.ELMA.Documents.Docflow.Web\Views\Resolution\ResultsExt.cshtml

\Web\Modules\EleWise.ELMA.Documents.Docflow.Web\Views\Shared\ResolutionGridExt.cshtml

Make changes to the files:

In the file \Web\Modules\EleWise.ELMA.Documents.Docflow.Web\Views\Resolution\Info.cshtml

in the line @{if(Model.Entity.Document.TypeUid == InterfaceActivator.UID<DocumentType>())

specify the required document type.

In the file \Web\Modules\EleWise.ELMA.Documents.Docflow.Web\Views\Shared\ResolutionGridExt.cshtml

in the line filter.Query = String.Format("DocumentAttachments in (Document = {0}) and CreationAuthor = {1} and DecisionV = true",document.Id,user.Id);

specify the boolean attribute added to the Task object.