Hello,
I’m trying to limit connections between two Accounts. For example, Account A can be connected to Account B in a “Branch - Managing company” relation only if those 2 accounts have the same owner.
I have tried to overwrite the Save function in AccountRelationshipDetailPageV2 and put a validation there. But for some reason it doesn't call the new function. Do you have any idea what's wrong with this approach?
Thank you,
Cristian Galatan.
Like
Hello Cristian,
Replace the BaseRelationshipDetailPageV2 schema (and not AccountRelationshipDetailPageV2). In the BaseRelationshipDetailPageV2 schema, create a validation method for the necessary fields (e.g., validateOneOwner()). This method should return an object with the invalidMessage parameter.
Override the onEntityInitialized() method. In the onEntityInitialized() method, call addColumnValidator() for each field with specifying the validation method. Use the following article for more details: https://academy.bpmonline.com/documents/technic-sdk/7-13/how-add-field-…
An example of code is below:
define("BaseRelationshipDetailPageV2", [], function() { return { entitySchemaName: "Relationship", methods: { onEntityInitialized: function() { this.callParent(arguments); this.addColumnValidator("AccountA", this.validateOneOwner); this.addColumnValidator("AccountB", this.validateOneOwner); }, validateOneOwner: function() { var message = ""; // the needed validation return { invalidMessage: message }; } }, details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/, diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/ };