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.

/wp-content/uploads/2016/08/automatically_message_onsave_1009258.png

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

automatically-message-onsave-CODE.png

DONE! Your result should be similar to this.

automatically-message-onsave-FIXED.png

To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

    1. 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. 🙁

      Bye,

          Horst

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

      (0) 
      1. 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.

        Regards,

        Richie.

        (0) 
      2. Victor Silva 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?

        (0) 
        1. 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.

          Bye,

             Horst

          (0) 

Leave a Reply