Edit Entity using business action
Level: Intermediate
Keywords: business action, edit feature, control edited attributes
The result: definition of intent and input form for editing entity using business action
How to edit an entity instance by a business action?​
This example describes the case when for editing existing instance of feature standard way is not sufficient, e.g. when some special check over edited date or some subsequent operations with edited data are needed. Also in case when edited data are the input for subsequent data processing. Editing of exising entity is activated by the means of an intent which activates the action form and subsequently specified business action.

Fig. 1. Intent icon in detail form header runs action form for editing data)
Definition of business-action intent​
The intent is used to make the business action available in the detail form, browse etc. The intent is represented by means of specified icon. Example below runs the subsequent business action after editing of Contract instance.
{
"title" : "Contract transformation",
"entitiesGroup" : "ft_contract",
"icon" : "icons:transformation",
"type" : "business-action",
"actionType" : "instance",
"display" : ["item", "detail"],
"actionId" : "transformContract",
"noResultDetail" : true,
"security": {
"loggedIn": true,
"hasAnyRole": ["CONTRACTS-EDIT", "CONTRACTS -ADMIN"]
}
}
Creating of action form​
In this case key-value-grid-form module is used for arranging data items within the Action form which is used for Contract instance editing. The name of Action form context is the same as the name of the business action.
{
"transformContract": {
"title": "Transforming contract type and related data",
"size" : "normal",
"sections": [
{
"module": {
"type": "component:dynamic-app/modules/forms/key-value-grid-form",
"title": "Basic data",
"rows": [
{
"elements": [
{
"label": "New type of contract",
"type": "codelist",
"property": "at_contract_cl_contractType",
"width" : 0.5,
"codelist": "cl_contractType",
"titleProperty": "ca_contractType_description",
"idProperty": "ca_contractType_id",
"disabled": true,
"validation": {
"required": true,
"validateOnChange": true
}
},
{
"label": "Contract category",
"type": "codelist",
"property": "at_contract_cl_contractCategory",
"width" : 0.5,
"codelist": "cl_contractCategory",
"titleProperty": "ca_contractCategory_description",
"idProperty": "ca_contractCategory_id",
"validation": {
"required": true,
"validateOnChange": true
}
}
]
},
{
"elements": [
{
"label": "Contract number",
"type": "numeric",
"property": "at_contract_number",
"width" : 0.2,
"validation": {
"min": 1,
"max": 99999999,
"required": true,
"errorMessage": "Enter a value from 1 to 99999999",
"validateOnChange": true
}
}
{
"label": "Date of transformation",
"type": "date",
"property": "at_contract_transformationDate",
"width" : 0.2,
"validation": {
"min" : 631209056000,
"max" : 4102385775000,
"required": false,
"validateOnChange": true
}
},
{
"label": "Reason for changing the contract type",
"type": "text",
"property": "at_contract_changeNote",
"width" : 0.6,
"validation": {
"minLength": 1,
"maxLength": 256,
"errorMessage": "Enter a string from 1 to 256 characters",
"validateOnChange": true
}
}
]
}
]
}
}
]
}
}
Registration of the relevant business action​
Bussiness action must be defined in given entity (feature type) business metadata. The name of action must be the same as name of Action form context.
{
"actions": {
"transformContract": {
"steps": [
{
"type": "script",
"source": "scripts/transformContract.js"
}
]
}
}
Creating of business action script​
Bussiness action script (JavaScript) is located and named based on parametr source from relevant action definition.