Skip to Content
Author's profile photo Victor Silva

Problem with New Feature Mandatory error message for OnSave validation

Hello community,

If you’ve read the What’s New on SAP Cloud Applications Studio 1608, you probably seen this.

Mandatory error message for OnSave validation

The system now displays an error message to the developer when a Save is rejected. There is an enhancement in the OnSave validation framework to check if any custom error messages are generated in the OnSave event while it returns false value. If not, the system displays a technical error message to explain which solution is responsible for the rejection.

Well, the problem is that you may have developed solutions and have raised some messages on the BeforeSave to improve performance or other specific reasons. In this case you’ve probable used a Transient flag to check if the object is valid or not. Then on OnSave you’ve just returned this flag, blocking then the Save.

In this scenario you will probably find an error message similar to this.


In order to remove this message, you will have to raise an ERROR message on the OnSave event. You can use something like this.


DONE! Your result should be similar to this.


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Richie Feeney
      Richie Feeney

      Thanks for this Victor, good to know 🙂

      Author's profile photo Horst Schaude
      Horst Schaude

      Hello Victor, Richie,

      To prevent a Save but not telling the customer why or where to look for the reason is ... aehhhhm ... not that good. 😉

      As background: The burden for such cases were laid on SAP in a lot of incidents. 🙁



      BTW: Similar to the other new message you are see if the generic QueryByElements is used and returns more than 1000 hits. 😯

      Author's profile photo Richie Feeney
      Richie Feeney

      I agree completely with you Horst and I understand why SAP were burdened with a lot of incidents. 😀

      If we prevent a save with custom code then we should raise a meaningful error message.



      Author's profile photo Victor Silva
      Victor Silva
      Blog Post Author

      Horst Schaude,

      The idea is to display the messages to the user, that's for sure!

      Let's say there are some heavy logic (with Queries and more) executed on the BeforeSave to update some fields and based on this logic you may want to block the save.

      In order to avoid replicating this logic into the OnSave, you could create an indicator transient field and store the "Is Valid" information. On BeforeSave you set this flag and raise the messages and on OnSave you use this flag to block saving, that's the idea. Does it make sense for you?

      Author's profile photo Horst Schaude
      Horst Schaude

      Hello Victor,

      Yes, that's fine so far.

      But I am also happy with the suggestion form this blog. 🙂

      You may have spread the logic in several places due to whaterver reasons.

      But you should have a "general" message to make sure that the user knows, that these other messages are the real root cause of blocking the Save.