ReplacementRuleItem

Substitution rule object

To create a substitution rule, use the System.replacements.rules.create method. After entering the information, save the rule by calling the ReplacementRuleItem.save method.

// Creating a  substitution rule for an employee 
const rule =  System.replacements.rules.create(); 
rule.data.__name = 'Rule';  
rule.data.absent = Context.data.__createdBy; 
rule.data.replacement =  Context.data.substitution; 
rule.data.filter = { 
  query: `[__name] =  ${Context.data.taskName} or [dueDate] < @p1`, 
  params: { p1: new Datetime ('2025-10-01T10:10:10') }, 
}; 
await rule.save(); 

Type parameters

Hierarchy

Properties

Readonly code

code: string

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

Readonly data

data: Based<Partial<ReplacementRuleData>>

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

Link target namespace (the code of the app's workspace).

Methods

fetch

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

save

  • save(): Promise<void>
  • Saving the substitution rule.

    Returns Promise<void>