Registering a document with a past date

This article provides an example of a process for registering a document with a past date.

The process uses the following context variables:

  • Document - Document object type;
  • Category - Category object type;
  • Reserved Number - Reserved Numbers object type;
  • Document Flow - Document Flow enumeration type;
  • Registration Date - Date/Time type;
  • Registration Number - String type.

Fig. 1. Process map

In the Registration Parameters task, you need to fill in the data for reserving a registration number and registering a document (fig. 2).

Fig. 2. "Registration parameters"

For the business process to work correctly, the scripts for reserving a number and registering the document must be executed in separate activities (fig. 1), otherwise, an error will occur.

To create a reserved number, use the ReservedRegNumberManager class.

Reserve Number script:

var newReg = ReservedRegNumberManager.Instance.Create ();
newReg.RegNumber = context.RegNumber;
newReg.Depository=context.Category;
newReg.Save ();
context.ReservedNumber = (ReservedRegNumber)newReg;
 

Register Document script:

Namespaces:

using EleWise.ELMA.API;
using EleWise.ELMA.Documents.Managers;
using EleWise.ELMA.Documents.Models.Nomenclature;
 
 
var regNumber = PublicAPI.Docflow.Document.Register(context.Document, context.Category, context.DocumentFlow.Value, context.ReserverdNumber);
context.ReservedNumber = null;
context.Document.RegistrationCard.FirstOrDefault ().RegistrationDate = context.DateReg;

You can find examples of other scripts for registering documents here.