We have two fields that are mandatory in mobile , but i can save the record even if they are not filled in which is weird and not usual !
This is the code :
Please any idea what may be the problem ?
Like
Two possible options:
1) You don't call the callback function at the end of this custom rule execution (Ext.callback(callbackConfig.success, callbackConfig.scope, [isValid]);). Here is a simple code of the rule I created locally:
Terrasoft.sdk.Model.addBusinessRule('Account', { ruleType: Terrasoft.RuleTypes.Custom, triggeredByColumns: ['AlternativeName'], events: [Terrasoft.BusinessRuleEvents.ValueChanged, Terrasoft.BusinessRuleEvents.Save], executeFn: function(record, rule, column, customData, callbackConfig) { var isValid = true; if (record.get('AlternativeName').length == 0) { isValid = false; record.changeProperty('AlternativeName', { isValid: { value: isValid, message: 'Column is empty' } }); } else { record.changeProperty('AlternativeName', { isValid: { value: isValid } }); } Ext.callback(callbackConfig.success, callbackConfig.scope, [isValid]); } });
2) You have isValid as true but still display the message and in fact the column is valid and you can save it and at the same time see the message under the columns
I setup a simple rule in my mobile app and it perfectly worked and prevented record saving in case the record is invalid
developer,
please share the code not in the screenshot next time. And also:
1) Did you debug its execution in the Android Studio?
2) Remove the "message" property when the isValid is true, it's not needed there
developer,
and additionally you always pass isValid value (that is always true) to the callback call:
This will also always allow to save the record.
developer,
yes, that's it. Tested locally and the record is saved when the callback is called with true even if some column isValid property is false. You need to change the logic in your code and modify and use the isValid property value in it using the example I shared above.