1. Home
  2. Administrators
  3. Formulas
  4. How to test JavaScript formulas in Docuo

How to test JavaScript formulas in Docuo

Formulas are used in Docuo for multiple purposes. From calculating the value of a field, to determining whether it is visible or not, or whether it should be locked.

Docuo’s formula editor allows you to test a JavaScript formula while it is being edited.

Testing JavaScript formulas before saving them ensures that they behave correctly without having to close the category editor and that the changes are applied to all documents in the category.

Suppose we have a Commercial Offers category with some price fields that include formulas:

Let’s edit the formula of the total field, which multiplies the price by the units and applies a discount percentage. To do this, select the field details and go to the options tab in the Formula section:

Click on the button on the right to access the formula editor:

To the right of the button bar we see “Test formula”:

In the pop-up side panel, we can test the formula. First we must choose whether we want to test with a new document window, or by choosing an existing document, in which case its data will be loaded.

Choose the “Use an existing document” option to debug specific cases, in documents where your formula does not behave as expected.

The green check indicates that the syntax is correct.

The field whose formula is being edited is shown in yellow.

We can then enter test data in the fields used in the formula to check that the calculations are correct.

You can modify the document state to see how the formula would behave in different states.

You can use the test panel with peace of mind, no document will be modified during the test, even if you have chosen it for testing.

You can make changes to the JavaScript formula while you have the test panel open. In this case, in order for the changes in the JavaScript code to be applied, you must click the “Execute” button.

Updated on 11 de May de 2023
Was this article helpful?

Related Articles