You can work with document categorization (folders), registration, and reservation of registration numbers, as well as with approval sheets and lists of informed users, using methods of the DocflowApplicationItemRef type.

Working with approval sheets and lists of informed users

You can get approval sheets and lists of informed users using the getApprovalLists and getInformLists methods. For instance, you can get approval sheets as follows:

const item = await Context. data.n1;
const approvalLists = await item.docflow().getApprovalLists(); 

You can continue working with these lists, for example, get statuses,
lists of approvers or informed users, creation or editing dates:

for (const list of approvalLists) {
    const {status,  respondents, createdAt: __createdAt} = list; 
} 

Approval sheets and lists of informed users are represented by the BaseList type.

Working with document categorization (folders)

You can get a specific folder using the DocflowApplicationItemRef.getNomenclature method. To get the folder data, you need to pass the folder’s ID. You can get it in two ways. Example of getting the folder’s ID from the app’s registration settings:

const settings = await Application.getSettings();
settings.registrationSettings.nomenclatureIds.forEach(nomenclatureId => {  
    ... 
}); 

Example of getting the ID from the list of registrations of the item of a Document type app:

const item =  Context.data.d1!
const registrations = item.docflow().getRegistrations();  
registrations.forEach(registration => { 
    const {nomenclatureId} =  registration; 
    ... 
}) 

The folders are represented by the TNomenclature type. Data acquisition and processing may look like this:

const item = Context.data.d1!
const settings = await  Application.getSettings(); 
const nomenclatures = []; 
for (const  nomenclatureId of settings.registrationSettings.nomenclatureIds) { 
     const nomenclature = await item.docflow().getNomenclature(nomenclatureId);  
    if (nomenclature !== undefined) { 
        const {id: __id, name:  __name} = nomenclature; 
        nomenclatures.push(nomenclature); 
    } 
}  

Registration and reserving registration numbers for apps

Each app can be registered in several folders if it is configured in the app’s settings. To get all registrations of a document, use the DocflowApplicationItemRef.getRegistrations method. Registrations are of ApplicationItemRegistration type. For example, you can get the IDs of folders where items of a Document type app can be registered as follows:

const item = Context.data.d1!
const registrations = await  item.docflow().getRegistrations(); 
for (const registration of registrations)  { 
    const nomenclatureId = registration.nomenclatureId; 
} 

To manage registrations, use the DocflowApplicationItemRef.register and
DocflowApplicationItemRef.deleteReservation methods. These methods expect the ID of the folder that an app item needs to be registered in or for which registration needs to be canceled. Example of registering an item of a Document type app in all folders specified in the app’s settings:

const item = Context.data.d1!
const settings = await  Application.getSettings(); 
settings.registrationSettings.nomenclatureIds. forEach(nomenclatureId => { 
     item.docflow().register(nomenclatureId);  
}) 

It is also possible to register an app item manually and specify the registration number. Manual registration is available if it is enabled in the folder’s settings. To register an item of a Document type app manually, use the DocflowApplicationItemRef.manualRegister method.
Example of manual registration:

const item =  Context.data.d1!
const settings = await Application.getSettings(); 
settings .registrationSettings.nomenclatureIds.forEach(nomenclatureId => { 
     item. docflow().manualRegister('Number 1', nomenclatureId); 
}) 

To reserve a registration number, use the DocflowApplicationItemRef.reserve method.
This method returns the reserved number. To cancel registration number reservation, use the DocflowApplicationItemRef.deleteReservation method.
Both methods expect the folder ID as the parameter. If an error occurs while reserving a number, an error will be generated. Example of reserving a number in a specific folder for an item of a Document type app:

const item = Context.data.d1!
const settings = await Application .getSettings(); 
const nomenclatures = []; 
for (const nomenclatureId of  settings.registrationSettings.nomenclatureIds) { 
    const nomenclature =  await item.docflow().getNomenclature(nomenclatureId); 
    if (nomenclature  !== undefined) { 
        nomenclatures.push(nomenclature); 
    } 
} 
const  nomenclatureName = 'Folder name'; 
const nomenclatureForReservation =  nomenclatures.find(nom => nom.name === nomenclatureName); 
if ( nomenclatureForReservation !== undefined) { 
    const reservedNumber =  await item.docflow().reserve(nomenclatureForReservation.__id); 
}