Skip to main content
Version: 8.1

Select a field by condition in the mobile app

Level: advanced
Example

Highlight the field with the result of the activity, if its status is "Completed", the Result field is not filled and the ProcessElementId column has a value.

Example implementation

Highlight the field by condition
// Rule for the activity edit page.
Terrasoft.sdk.Model.addBusinessRule("Activity", {
// The name of the business rule.
name: "ActivityResultRequiredByStatusFinishedAndProcessElementId",
// Business rule type: custom.
ruleType: Terrasoft.RuleTypes.Custom,
//The rule is initiated by the Status and Result columns.
triggeredByColumns: ["Status", "Result"],
// The rule will work before saving the data and after changing the data.
events: [Terrasoft.BusinessRuleEvents.ValueChanged, Terrasoft.BusinessRuleEvents.Save],
// Handler function.
executeFn: function(record, rule, column, customData, callbackConfig) {
// A flag of the validity of the property and the rule.
var isValid = true;
// The value of the ProcessElementId column.
var processElementId = record.get("ProcessElementId");
// If the value is not empty.
if (processElementId && processElementId !== Terrasoft.GUID_EMPTY) {
// Set the validity flag.
isValid = !(record.get("Status.Id") === Terrasoft.Configuration.ActivityStatus.Finished &&
Ext.isEmpty(record.get("Result")));
}
// Change the properties of the Result column.
record.changeProperty("Result", {
// Set the column correctness indicator.
isValid: {
value: isValid,
message: Terrasoft.LS["Sys.RequirementRule.message"]
}
});
// Asynchronous return of values.
Ext.callback(callbackConfig.success, callbackConfig.scope, [isValid]);
}
});