- Home [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
- Getting started
- Manage types
- Global context and isolation
- Manage apps
- Batch actions with app items
- Manage external services
- Scripts in widgets
- Web components
- Access permissions
- Getting started with processes
- Getting started with signatures
- Getting started with file previews
- Getting started with the organizational chart
- Getting started with users and groups
-
Getting started with the
Table data type - Use cases
- How to set up custom view of app items
- How to set up dynamic display of fields and widgets with a complex condition
- How to register a document
- How to calculate the number of days between two dates
- How to create a substitution for a user
- How to use pagination and sorting when searching for app items
- API
- Object types
- Data types
- Global constants
- Work with apps
- Web requests
- Access permissions
- Document flow
- Live Chats
- “Code” widget
- Signatures
- Business calendars
- Integration with IP telephony
- Integration with email marketing services
In this article
How to create a substitution for a user
When an employee is on holiday, on sick leave, on a business trip, or absent for some other reason, he or she is usually temporarily substituted by another employee.
The information about substitutions needs to be added to the system and shown to other employees, and tasks assigned to the absent employee need to be reassigned to the substitute.
You can learn more about how substitutions work and how to create a substitution manually in the Substitute users in the Help Center.
In this article, you will learn to create substitutions automatically using a custom script.
Let’s say we need to create a substitution for an employee who is going on a business trip. The substitution is created in a business process that starts when a new item of the Business trips app its saved.
When you create a substitution, you need to specify the employee who is going to be absent, the substitute, and the dates of the business trip.
When a new business trip is saved, a business process starts. Its diagram needs to include a script that creates a new substitution.
Script
Let’s add the Script activity to the Business trip process and write the code presented below.
It is important to fill out all the attributes of a substitution in the script. These are Type, Absent user, Substitute, Start date, and End date.
After filling out the attributes, we need to save the new substitution.
async function createReplacement(): Promise<void> { \t/* Getting the item of the Business trips app \twhose data will be used to create the substitution */ \tconst trip = await Context.data.trip.fetch(); // Creating a substitution item const newReplacement = System.replacements.create(); /* Specifying the substitution’s type: Inform (`information`), Reassign tasks (`reassign`), or Grant all access permissions (`full`) */ newReplacement.data.type = newReplacement.fields.type.variants.information; // Specifying the absent user (in our case, it is the user who is going on the business trip) newReplacement.data.absent = trip.data.traveller; // Specifying the substitute newReplacement.data.replacement = trip.data.replacer; // Specifying the start date and end date using the dates of the business trip from the context newReplacement.data.begin = trip.data.trip_start_date; newReplacement.data.end = trip.data.trip_end_date; // Saving the substitution item await newReplacement.save() }
Result
When the script in the business process is executed, a new substitution appears in the system.