Hi everybody,
the task is to make activity's "Result" and "Detailed result" fields required for competed "Status". The same trouble was discussed here. Without result indeed. Here's a kind of realization of the similar task.
As I am not a great master of the Mobile app customization, some help will be welcomed. The problem was tried to be solved like this:
Terrasoft.sdk.Model.addBusinessRule("Activity", {
name: "UsrResultByStatusRequirement",
ruleType: Terrasoft.RuleTypes.Requirement,
requireType : Terrasoft.RequirementTypes.Simple,
events: [Terrasoft.BusinessRuleEvents.ValueChanged, Terrasoft.BusinessRuleEvents.Save],
triggeredByColumns: ["Status"],
conditionalColumns: [
{name: "Status.Finish", value: true},
],
dependentColumnNames: ["Result"]
});and also like this:
Terrasoft.sdk.Model.addBusinessRule("Activity", {
name: "UsrResultByStatusRequirement",
ruleType: Terrasoft.RuleTypes.Custom,
triggeredByColumns: ["Status"],
events: [Terrasoft.BusinessRuleEvents.ValueChanged, Terrasoft.BusinessRuleEvents.Save],
executeFn: function(record, rule, column, customData, callbackConfig) {
var isRequired;
var status = record.get("Status");
if (status && (status.get("Id") === Terrasoft.ActivityStatus.Finished || status.get("Id") === Terrasoft.ActivityStatus.Canceled)) isRequired = true;
record.changeProperty("Result", {
isValid: {
value: isRequired,
message: "Column must be filled in"
}
});
Ext.callback(callbackConfig.success, callbackConfig.scope, [isRequired]);
}
});both don't work. This one works, but doesn't do what is needed
Terrasoft.sdk.Model.addBusinessRule("Activity", {
name: "DetailedResultByStatusRequirement",
ruleType: Terrasoft.RuleTypes.Requirement,
triggeredByColumns: ["Result"]
});Where's the problem please?
Like
3 comments
16:18 Jul 02, 2025
Hi Dmitry, It's better to set default value of false for isRequired to avoid potential undefined issues.
Could you please share the error details?
17:22 Jul 07, 2025
Pavan Manne,
I was recently too tired to deal with conditions. This one works nice :)
Terrasoft.sdk.Model.addBusinessRule("Activity", {
name: "UsrResultByStatusRequirementRule",
ruleType: Terrasoft.RuleTypes.Custom,
triggeredByColumns: ["Status", "Result"],
events: [Terrasoft.BusinessRuleEvents.ValueChanged, Terrasoft.BusinessRuleEvents.Save],
executeFn: function(record, rule, column, customData, callbackConfig) {
debugger;
var isValidResult = true;
var status = record.get("Status");
if (status) {
isValidResult = !(
(record.get("Status.Id") === "4bdbb88f-58e6-df11-971b-001d60e938c6" || record.get("Status.Id") === "201cfba8-58e6-df11-971b-001d60e938c6") &&
Ext.isEmpty(record.get("Result")));
}
record.changeProperty("Result", {
isValid: {
value: isValidResult,
message: "Result must be filled in"
}
});
Ext.callback(callbackConfig.success, callbackConfig.scope, [isValidResult]);
}
});
Show all comments