Configuring a category list in the business process task
This article will be helpful if you want to create a convenient list of categories for a user. If you simply place a context variable of the Category type on the task form, the drop-down list will contain all kinds of categories.
This example allows you to implement a selection of the categories of the Incoming Document type (current records classification scheme). Thus, a user will see a short list of categories and does not need to search through a vast number of items.
If necessary, you can change a document type by replacing the GUID of the document.
Creating a service object
Open ELMA Designer:
- In the Objects tab, create a new object with the Service name. Go to the Script tab of the object. Add the following code to the script, using the following assemblies beforehand:
using EleWise.ELMA.ComponentModel;
using EleWise.ELMA.Documents.Managers;
using EleWise.ELMA.ExtensionPoints;
using EleWise.ELMA.Model.Entities.EntityReferences;
using EleWise.ELMA.Model.Metadata;
using EleWise.ELMA.Model.Services;
using NHibernate.Criterion;
Script:
[Component]
public class MyReferenceOnEntityTypeQueryResult : IQueryFunctionResult
{
public string FunctionName
{
get { return "MyReferenceOnEntityType"; }
}
public IProjection GetProjection(EntityMetadata metadata, string propName, object[] parameters)
{
return Projections.Constant(GetValue(metadata, propName, parameters));
}
public object GetValue(EntityMetadata metadata, string propName, object[] parameters)
{
if (parameters.Length == 1 && parameters[0] is string)
return new ReferenceOnEntityType{ TypeUid = new Guid((string)parameters[0])};
throw new ArgumentException();
}
}
Preparing the Category Object
Then you need to prepare the Category Object: add a link to a class, which cashes the current records.
- In the Object tab, find the Category object (Documents-Records-Category).
- Create a new property named Published Records (PublishedRecords):
- Type – class, which cashes the published records
- Link Type –Multiple (1-N)
- Key Column –Category
Saving and Publishing Objects
- Save and publish Category and Service objects.
- Go to the Publishing tab and click the Restart Server button.
Usage Example
Create a user task in a business process. The task must contain a variable of the Category type. Suppose the task form contains a drop-down list of the categories of the Incoming document type of the current records. Create a script on the form load LoadFormSc.
The script on the form load:
var settings = ((EntitySettings)context.GetSettingsFor(c => c.Delo));
settings.FilterQuery = " PublishedRecords in (DocumentType in (MyReferenceOnEntityType(’C151A3B3-220D-443A-A054-A0345A869961’)))";
settings.Save();
Where :
- PublishedRecords – the name of the property type ‘Class, which cashes the published records’ of the category object
- ’C151A3B3-220D-443A-A054-A0345A869961’– GUID of the document type “Incoming Document”. To determine the GUID of the necessary document type, go to > Administration > Records Management > Document Types; then go to the page of the necessary document type. The URL of the page will look like: http://server address/Documents/DocumentMetadata/Settings?uid=C151A3B3-220D-443A-A054-A0345A869961, where C151A3B3-220D-443A-A054-A0345A869961 is the GUID of the document type
- с.Category– variable of the Category type from the task context.