You are using the standard functionality of attachments and implemented a custom validation to verify the files to be attached.
You have implemented this scenario in the ABC (ABC stands for the view name) view of the XYZ (XYZ stands for the work center name) work center.
When adding a new attachment to an instance which is already created your event before save is not triggered as you expects.
- SAP Cloud for Customer
- SAP Business ByDesign
- SAP Cloud Applications Studio
Reproducing the Issue
Go to XYZ work center.
Open ABC view.
Select an entry.
Click on Edit.
In the Attachments Session click on Add.
Upload an inconsistent file (according to the validation you created).
Click on Save.
Your entries will be saved and the event before save will not be called.
If you modify the value of any field in the header of this entry and click on Save, the event before save will be triggered. In this case the validation will occur for all the files you have attached.
The framework does not count the change in the attachment folder as a change in the instance, hence the validations are not called.
Attachment Folder is an association within the custom BO(stands for Business Object) and just changing the content of it would not trigger the validations once the custom BO Instance is already created.
If you use the Trace Funtion on SDK while trying to add an attachment in an already created instance you will see in the trace results that anything was called and because of it the save was successful.
If a field on Root Node is changed before clicking on save, the validations are called and the scenario works as expected. It happens because when you change a field in Root Node the framework understands the instance was changed and the validations happen for the entire instance and its associations, hence the validations on the attachments must happen again.
To overcome this scenario some modeling adjustments on ABSL would be needed.
In case of further questions on ABSL Implementation, please reach out to our SAP Cloud Applications Studio Community.
Attachment; Validation; Before; Save; , KBA , AP-RC-BDS-BO , ByDesign Studio BO definition/generation , How To