Mobile requirement rule by other column value

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 0

Like

2 comments

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?

Pavan Manne,

I'll try to debug it tomorrow, but as I understand, code has no errors :) 

Show all comments