cancel
Showing results for 
Search instead for 
Did you mean: 

Event-BeforeSave and Validation-OnSave

Former Member
0 Kudos

Hello all,

Event-BeforeSave is executed before Validation-OnSave is executed

In Validation-OnSave - I have made a check to throw an error.

After throwing an error, the user fills up the mandatory field and click on save again.

However this time Event-BeforeSave is not executed anymore.

Is this the correct behavior in the system?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Tommy,

The setup you describe should work - well it works for us.

Here is how we do it:

*.bo:


element allowSave : Indicator;

Event-BeforeSave.absl:


if (mandatoryField.IsInitial()) {

    this.allowSave = false;

} else {

    this.allowSave = true;

}

Validation-OnSave.absl:


return this.allowSave;

Best regards,

Ludger

Former Member
0 Kudos

I have an XBO on AP.FO.BusinessPartner.Global:Customer

I have set the breakpoints in Event-Beforesave and Validation-OnSave

The first time it runs, it breaks into Event-Beforesave and then Validation-OnSave which returns false.

The second time when it runs, Event-Beforesave is not executed anymore. Only Validation-OnSave is executed.

Jacques-Antoine
Active Participant
0 Kudos

Hello Tommy,

This is weird as normally the data has changed. First the field is empty, then you fill it. So it should have a Before-Save triggered in order to save the newly populated field.

Did you try an After-modify to see the difference of behavior after filling the mandatory field?

Best regards.

Jacques_Antoine

sumeet_narang
Active Participant
0 Kudos

Hi Tommy,

I am just guessing here. Could you please check once what is the Deployment unit of the solution you have created. Since you are extending the customer, it should be Foundation.

Regards,

Sumeet

Former Member
0 Kudos

Hello,

After modify get executed again after Validation Onsave.

Event beforesave only get executed once.

I have decided to put my code in after modify instead of event beforesave...

Jacques-Antoine
Active Participant
0 Kudos

Hello Tommy,

Nice to see that it worked!

But you should investigate further this weird behavior.

Best regards.

Jacques-Antoine Ollier

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Jacques-Antoine,

I've retested it with the BusinessPartner in our internal systemand it worked as described:

  1. Determination BeforeSave is called
  2. Validation OnSave is called and returns message + False
  3. User input
  4. Determination BeforeSave is called
  5. Validation OnSave is called

Maybe you should raise an incident.

Sorry,

  Horst

sumeet_narang
Active Participant
0 Kudos

Hello Tommy,

In Validation-OnSave you must have set the flag to False to throw an error. I think you need to set that flag to True once the mandatory field is filled. This should make the event Before Save to call again.

Regards,

Sumeet