Adding a new action to a visit in field force
Glossary Item Box
ATTENTION The functionality described in this article is available for bpm'online version 7.11.2 and higher, as well as for all versions of the mobile application. |
Introduction
The action on the activity view page is a switch with two states:
- done - the switch is on
- not done - the switch is off.
If you want to change the behavior of an existing action or add a new one, you need to register the handler class of this action with the execute() and cancel() methods. The handler class is bound to the code of the action (FieldForceActionType.Code). By default, the action uses the Terrasoft.configuration.BaseVisitAction base class handler.
The Terrasoft.configuration.BaseVisitAction class
The Terrasoft.configuration.BaseVisitAction class has two main methods – execute() and cancel().
The execute() method
The method is called when the switch is turned on. Saves a record of the visit action (VisitActions) with the following column values:
IsComplete – true
CompleteTime – current time.
The cancel() method
The method is called when the switch is turned on. Saves a record of the visit action (VisitActions) with the following column values:
IsComplete – false
CompleteTime – null.
Handler classes of existing actions
The handler classes for existing actions that are used depending on the action code (FieldForceActionType.Code) are listed in Table 1.
Table 1. Handle classes of actions
The code of the FieldForceActionType.Code action | Class name |
---|---|
CheckIn | Terrasoft.configuration.CheckInVisitAction |
CheckOut | Terrasoft.configuration.CheckOutVisitAction |
ShowPresentation | Terrasoft.configuration.PresentationVisitAction |
AcceptanceOrder | Terrasoft.configuration.AcceptanceOrderVisitAction |
SKUMonitoring | Terrasoft.configuration.SKUMonitoringVisitAction |
Adding a user action
For example, you need to add a user action of opening a detail page. To do this:
1. Create a handler class in which you want to extend the base execute() method, called when the action is executed. The complete source code of the schema is available below:
Ext.define("Terrasoft.configuration.OpenMyStandardDetailVisitAction", { extend: "Terrasoft.configuration.BaseVisitAction", execute: function() { Terrasoft.util.openStandardDetail({ parentRecord: this.getActivityRecord(), detailModelName: "MyStandardDetail" }); this.completeWithSuccess(); } });
The completeWithSuccess() method stores a visit action record (VisitActions) with filled columns (IsComplete - true and CompleteTime - current time). The success function is then called to confirm the successful completion of the action.
2. Bind the handler class to the action code. An example of the source code for binding a handler to the action code is shown below:
Terrasoft.configuration.VisitActionsManager.add("OpenMyStandardDetailActionCode", "Terrasoft.configuration.OpenMyStandardDetailVisitAction");
You can bind a single handler class to multiple actions.
Terrasoft.configuration.VisitActionsManager.add("OpenMyStandardDetailActionCode2", "Terrasoft.configuration.OpenMyStandardDetailVisitAction");
Extending the base logic of the action
The base logic for performing actions is implemented in the Terrasoft.configuration.BaseVisitAction class. To execute a common code for all user actions, it is not necessary to register a handler class for each action. You can set the default action class, for example:
Ext.define("Terrasoft.configuration.MyBaseVisitAction", { extend: "Terrasoft.configuration.BaseVisitAction", execute: function() { this.callParent(arguments); //Implementing a common user logic. //... } }); Terrasoft.configuration.VisitActionsManager.setDefaultItemClassName ("Terrasoft.configuration.MyBaseVisitAction");