Type parameters

Hierarchy

Properties

Readonly code

code: string

App code of the URL’s target (the app’s code).

Readonly data

data: Based<Partial<Data>>

Values of object’s fields.

Readonly fields

fields: Readonly<object>

Description of the object’s fields.

Readonly id

id: string

ID of the URL’s target.

Readonly namespace

namespace: string

Namespace of the URL target (the code of the workspace that the app belongs to).

Methods

delete

  • delete(): Promise<void>
  • The method allows you to delete an app item.

    await Context.data.app.delete();
    

    Returns Promise<void>

docflow

  • This method returns an object to work with document management operations.

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

    Returns DocflowApplicationItemRef

fetch

getDataSigns

  • The method receives the internal signature of the app’s data.

    While calculating internal signatures of an app, the system considers user signing settings. The data it obtains consists of a set of signatures of two types, for attributes and for files. Each signature includes:

    • hash: signature applied to the app’s data.
    • body: data that hash is calculated for.
    • type: signature type. In the example below, the context includes:
    • document1: a Document type app that includes signature settings In the example, the system searches for the signature and uses hash and body to save the obtained signature.
      const app = await Context.data.document1.fetch();
      const dataSigns = await  app.getDataSigns(); 
      const dataSign = res.find( (res: any)  => res.type ===  SignType.File); 
      const newSign: NewSign = { 
        sign: 'aGVsbG8=', 
         codeProvider: 'External', 
        body: btoa(app.data.__file!.id), 
        hash:  dataSign.hash 
      } 
      await app.uploadSign(newSign); 
      

    Returns Promise<SignData[]>

getFolder

  • getFolder(): Promise<TFolder | undefined>
  • The method returns the folder from the folder tree that an item is in.

    const item = await Context.data.n1;
    const folder = await item. getFolder(); 
    

    Returns Promise<TFolder | undefined>

getPermissions

  • The method retrieves access permissions set for the app item.

    Use this method if you need to add new access permissions to the existing ones.

    // Let’s grant the process initiator access to the app  item 
    const item = await Context.data.request.fetch(); 
    const user = Context. data.__createdBy; 
    // We need to retrieve the current access permissions  
    const currPermissions = await item.getPermissions(); 
    currPermissions.values .push(new PermissionValue(user, [PermissionType.READ])); 
    await item. setPermissions(currPermissions); 
    

    Returns Promise<TPermissions>

getRegistrations

  • Deprecated. Get a list of registrations of an app item.

    const item = Context.data.d1!
    await item.getRegistrations(); 
    
    deprecated

    As the method is deprecated, use docflow instead:

    const  item = Context.data.d1!
    await item.docflow().getRegistrations(); 
    

    Returns Promise<ApplicationItemRegistration[]>

getSettings

  • The method returns an app’s settings.

    const app = Context.data.dokument;
    if (app === undefined) { 
     return; 
    } 
    const settings = await app.getSettings(); 
    

    Returns Promise<TSettings>

getSignHistory

  • The method gets the history of an app item’s signatures.

    // Example of saving signatures to context variables of the  File type 
    const app = await Context.data.dokument!.fetch(); 
    const  signHistory = await app.getSignHistory(); 
    Context.data.sign_attributes =  await signHistory[0].signs[0].createSignFile(); 
    const attributes = await  signHistory[0].signs[0].createAttributesFile(); 
    if (attributes !==  undefined) { 
     Context.data.attributes = attributes; 
    } 
    

    Returns Promise<EntityVersion[]>

getSubscribers

  • getSubscribers(): Promise<TUser[]>
  • List of users subscribed to the app item’s activity stream.

    // Let’s write the app item’s subscribers to the context  
    const subscribers = await item.getSubscribers(); 
    Context.data.subscribers =  subscribers; 
    

    Returns Promise<TUser[]>

hasPermission

  • hasPermission(orgunit: TPermissionOrgunit, type: PermissionType): Promise<boolean>
  • The method checks permissions of a user, group, org chart item, or role.

    Parameters

    • orgunit: TPermissionOrgunit

      User, group, org chart item, or role that has the permissions.

    • type: PermissionType

      Access permissions type.

      const procurement = await Context. data.procurement.fetch();
      const user = Context.data.executor; 
      await  procurement.hasPermission(user, PermissionType['READ']); 
      

    Returns Promise<boolean>

manualRegister

  • manualRegister(nameReg: string, nomenclatureId: string): Promise<boolean>
  • Deprecated. Manual registration of an app item (if manual registration is enabled in the folder’s settings).

    deprecated

    As the method is deprecated, use docflow instead:

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

    Parameters

    • nameReg: string
    • nomenclatureId: string

    Returns Promise<boolean>

normalize

  • normalize(): void
  • Delete duplicate data in arrays.

    The method deletes duplicates in fields that store arrays of links to system objects (users, files, app items, or documents). For example, you can call this method after bulk editing data within an object.

    const  app1 = await Context.data.app1.fetch();
    const app2 = await Context.data.app2 .fetch(); 
    app1.data.executors.push(app2.data.executors); 
    app1.normalize();  
    // Now we need to go over the elements in the new array 
    app1.data.executors .forEach( ... ); 
    

    Returns void

register

  • register(nomenclatureId: string): Promise<boolean>
  • Deprecated. Automatic app item registration.

    deprecated

    As the method is deprecated, use docflow instead:

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

    Parameters

    • nomenclatureId: string

    Returns Promise<boolean>

restore

  • restore(): Promise<void>
  • The method allows you to restore a deleted app item.

    await Context.data.app.restore();
    

    Returns Promise<void>

save

  • save(): Promise<void>
  • The method saves an app item.

    You need to save app items when their data changes.

    const  request = await Context.data.service_request.fetch();
    request.data.responsible = Context.data.responsible; 
    await request.save();  
    

    Returns Promise<void>

sendMessage

  • sendMessage(title: string, message: string): Promise<void>
  • The method allows sending messages to an app item’s activity stream.

    Parameters

    • title: string

      Message subject.

    • message: string

      Message body.

      await Context.data.request.sendMessage('The  work on your request has been completed', `Solution: ${Context.data.result}`)
      

    Returns Promise<void>

setFolder

  • setFolder(id: string): Promise<void>
  • The allows you to change the app item’s folder in the Folder hierarchy.

    Parameters

    • id: string

      Folder ID.

      const item = await Context.data.n1;
      await item. setFolder('00000-00000-00000-00000'); 
      

    Returns Promise<void>

setPermissions

  • The method sets new access permissions for an app item.

    This method completely replaces the existing permissions with new ones.
    There is no point to configure the permission to create an existing app item, so the PermissionValue.Create value is not available.

    Parameters

    • permissions: TPermissions

      Access permissions that will be set for the app item.

      const  procurement = await Context.data.procurement.fetch();
      const user = Context. data.executor; 
      const permissions = new Permissions( 
      [new PermissionValue( user, [PermissionType.DELETE, PermissionType.READ])]); 
      await procurement. setPermissions(permissions); 
      

    Returns Promise<void>

setStatus

  • setStatus(status: TStatus<any, any>, comment?: undefined | string): Promise<boolean>
  • The method changes the status of an app item.

    The status changes immediately after the method is executed. You don’t need to call the ApplicationItem.save method.

    Parameters

    • status: TStatus<any, any>

      Status.

    • Optional comment: undefined | string

      Reason for the status change.

      const request = await Context. data.request.fetch();
      const finalStatus = request.fields.__status.variants. completed; 
      await request.setStatus(finalStatus, 'Closed automatically');  
      

    Returns Promise<boolean>

subscribe

  • subscribe(user: TUser): Promise<void>
  • The method allows you to subscribe a user to updates in the activity stream of an app item.

    Parameters

    • user: TUser

      User.

      // You can subscribe the current user to an app item’s  activity stream 
      const item = await Context.data.app.fetch(); 
      const user =  await System.users.getCurrentUser(); 
      await app.subscribe(user); 
      

    Returns Promise<void>

unsubscribe

  • unsubscribe(user: TUser): Promise<void>
  • The method allows you to unsubscribe a user from updates in the activity stream of an app item.

    Parameters

    • user: TUser

      User.

      // You can unsubscribe the current user from an app  item’s activity stream 
      const item = await Context.data.app.fetch(); 
      const  user = await System.users.getCurrentUser(); 
      await app.unsubscribe(user);  
      

    Returns Promise<void>

uploadSign

  • uploadSign(sign: NewSign): Promise<boolean>
  • The method uploads a digital signature.

    The method is used to create a custom signing mechanism for apps. You can use it to apply a signature obtained from an external signature provider to an app. To use this method, you need:

    • Byte content of the signature in the Base64 format.
    • Signature type.
    • Signature provider’s code (a string constant that identifies it).
    • Hash of the app data that was signed.
    • Data based on which the signature was calculated. In the example:
    • document1 is a Document type app in the context.
    • The MySignProvider class is an example signature provider. The method returns a flag that indicates the status of the upload. If the flag evaluates to true, the upload of the signature is successful; false means that the upload failed.
      const app = await Context.data.document1. fetch();
      const provider = new MySignProvider(); 
      const innerSigns = await  Conetxt.data.document1.getDataSigns(); 
      const attributesInnerSign =  innerSigns.find(sign => sign.type === SignType.Attributes); 
      const sign =  provider.Sign(attributesInnerSign.body); 
      const newSign: NewSign = { 
         sign: sign, 
        codeProvider: 'MyProvider', 
        body:  attributesInnerSign.body, 
        signType: SignType.Attributes, 
        hash:  attributesInnerSign.hash, 
      }; 
      const isUploaded = await app. uploadSign(newSign); 
      

    Parameters

    • sign: NewSign

      Data needed to upload the signature.

    Returns Promise<boolean>