The Control step of Docuo’s Category Wizard is the right place to prevent your users from performing an action even when folder and category permissions allow them to do so.
It is possible to create a control that checks a condition before saving a document. We can also prepare an error message explaining to the user why he/she cannot save when the condition is not met.
We will explain the operation of this type of control with an example. Suppose we have a category with the following fields:
In our example we want to prevent documents with a total price of less than 1,000 euros from being saved.
To do so, we create a new control:
The new control creation window allows you to set what you want to control by means of two drop-down lists
Selection of the action to be controlled
The first thing to do is to choose the action you want to control from the drop-down list on the right. In this case we will choose “Save documents that meet the following condition”.
Creating the condition formula
Then we must enter the condition we want to verify in the control by means of a JavaScript formula.
In our case, the formula should return the empty string when the total price of the offer exceeds 1.000 €, and an error message otherwise:
if(<@Offer pricing:Total> >= 1000){
return '';
} else {
return 'No es posible guardar ofertas de menos de 1.000 €';
}
Choose which users the control should apply to
The next thing to do is to choose which users will be affected by the control. This is done by assigning users and groups:
In our case, we will choose the commercials. They will not be able to keep bids of less than 1.000 €.
Choose what happens to other users
In Docuo you can set controls that affect only a group of users or that, in addition, prevent an action for the rest. To do so, we display the “Action” list:
If you choose “Prevent”, the users you specify will be affected by the control, but the rest of the users will be able to perform the action.
If you choose “Control only”, the users you specify will also be affected by the control, but the rest of the users will not be able to perform the action.
Thus, in our case, if we choose “Prevent”, users who are not in the “Commercial” group will be able to save offers of less than 1,000 €.
If we were to choose “Check that only”, the rest of the users would not be able to save offers.