A110 – Create a specific action
What you will learn ?
How to add a specific action on a business object
STEP 5: Configure the action
- Name: for example prefix with the name of the object and a qualifier for the action
- Type: it is the display type, it can be Hidden or Enable on list (action on all records of the current search) and / or in the object form.
- Asynchronous: Synchronous (blocking the user) or Asynchronous (to give the hand to the user if the action is long)
- Async jobs depth : Indicate the depth of log traces. if the number is positive it is in quantity, if the number is negative it is in rolling days.
- Method: a method name coded in each object that will use the action
- Enter an Image URL to represent the action, if none the action will be displayed as a button
- Indicate whether the action must be confirmed by the user
- If it is displayed in the Plus menu
- Select the module
Create the action that will calculate the customer score by script:
- Name = AppClient-Score
- Enable on form only
- Without confirmation from the user
var clientId=obj.getRowId(); var sql = "select sum (a.int_score)" + " from app_interet a, app_client_interet b" + " where a.row_id = b.cint_interet_fk and b.cint_client_fk =" + clientId; var score = obj.getGrant().simpleQueryAsLong(sql); obj.getField("cliScore").setValue(score); obj.save();
Explanation of the script line by line:
- Found the customer row_id on which the action is called
- Defines a SQL query that calculate the sum of the customer score
- Run the query
- Set the cliScore value
- Save the customer
Fill in the form of the function:
- Give a name to the function: by convention we use the same name as the action
- Select the object that will carry the action (so we can create several functions using the same action for different objects)
- Select the function type = Action
- Select the module Save.
Create a function on the action
STEP 11: Test the action
Open the object containing the action and check that it performs well what is set.
- Open a customer who has interests
- Check that the total calculation works by clicking on the button
If action is not visible is that the user is not in a group granted to the function of the action.
If the calculation does not work, look out for the logs and fix the code.
Remember to clear the cache at each update.