Getting started

The Pyrus scripting platform lets users expand the functionality of Pyrus forms to do things like:

  • Automatically calculate and fill in field values based on data entered in other fields.
  • Validate field values.
  • Automatically fill in fields using the form register.

The scripts are written in JavaScript and executed within Pyrus forms. The platform provides a trusted environment to run these scripts and controls their access to your data.

To try out Pyrus scripts, follow these steps:

  1. Create a form that contains the fields Start date, End date and Duration. This might be a request form for a business trip or vacation.
  2. Open the form’s settings and click on Edit script.
  3. Insert the following code into the script editor:
      form.onChange(['Start date', 'End date'])
      .setValue('Duration', state => {
        const startDate = state.changes[0].date;
        const endDate = state.changes[1].date;
        if (!startDate || !endDate)
          return [null];
        const diff = daysBetween(new Date(startDate), new Date(endDate));
        return [diff + 1];
    function daysBetween(d1, d2) {
      const msInDay = 1000 * 60 * 60 * 24;
      return Math.floor((d2.getTime() - d1.getTime()) / msInDay);
  4. Save your changes.
  5. Open a new business trip or vacation request form, then fill in the Start date and End date fields. The Duration field will automatically show the number of days requested:

Was this article helpful?

Yes, thanks! No, I have a question