如何给SAP Cloud for Customer UI上的字段添加自定义校验逻辑

There is a good blog SAP Cloud for Customer Phone Number Parsing and Formatting which gives a detail explanation about the parse logic of phone number parse logic in C4C. By default it allows the Alphanumeric Value to be entered, the reason of this behavior is explained in note 2525818 – In an Account and Contact, the Phone Number Allows Alphanumeric Value.


However, at least in China, a valid mobile phone number only consists of pure numeric values. The requirement of local customer is whenever the value other than pure number is maintained, the error message will be popped up and the save is terminated.


The fulfilled scenario is: for example if I input an “A” character in Mobile field and press save button, error message is raised:如何给SAP Cloud for Customer UI上的字段添加自定义校验逻辑Here below is how to achieve this custom validation logic in Cloud Application Studio.

Create an extension field phoneInvalidRel in BO BusinessPartnerRelationship, and declare the error message to be raised when invalid digit is detected.如何给SAP Cloud for Customer UI上的字段添加自定义校验逻辑Implement BeforeSave event. This event is responsible to check whether the mobile phone number consists of pure numeric value and set the check result into extension field phoneInvalidRel, which will be used by onSave Validation later.如何给SAP Cloud for Customer UI上的字段添加自定义校验逻辑Implement OnSave validation, and simply use the check result stored in extension field phoneInvalidRel.如何给SAP Cloud for Customer UI上的字段添加自定义校验逻辑In the runtime, when I enter “A” in mobile phone field and save, first the BeforeSave event is triggered,如何给SAP Cloud for Customer UI上的字段添加自定义校验逻辑And then the onSave Validation is called.如何给SAP Cloud for Customer UI上的字段添加自定义校验逻辑The above implementation could only cover the scenario that end user directly changes the mobile phone number which is technically modelled in BO BusinessPartnerRelationship. There is another possibility that end user will also changes the field on Root node of BO BusinessPartner, as a result the same logic should be done again on BO BusinessPartner as well.如何给SAP Cloud for Customer UI上的字段添加自定义校验逻辑BeforeSave implementation on BusinessPartner Root node:如何给SAP Cloud for Customer UI上的字段添加自定义校验逻辑OnSave Validation on BusinessPartner Root node:如何给SAP Cloud for Customer UI上的字段添加自定义校验逻辑


上一篇:轻松建站,20个PHP开源内容管理系统(CMS)推荐


下一篇:Java开源CMS系统