cancel
Showing results for 
Search instead for 
Did you mean: 

Not execute before save action in extension(XBO) PDI

0 Kudos
  1. At the moment that I release an Outbound Delivery document you can see the system raises a standard error, for example in this case because the logistic area doesn’t have enough stock (but can be another kind of error).
  2. In my customer solution I have ABSL code in the before save action. However, this is being executed even if the system raises a standard error.

My need is that the ABSL code shouldn’t be executed at the moment the system raises an error. Only when the document - by standard - will be save because doesn’t have any error.

Accepted Solutions (0)

Answers (4)

Answers (4)

stefankrauth
Active Participant

Hello,

All BeforeSave events are exected. The system collects the error messages and shows them after all events have been run. The data will NOT be written to the database as long as one ValidationOnSave script (standard or custom) will return false.

It's not possible to detect a fully error free document and then run some code. Because this code could again throw an error - and what should happen then?

The framework runs all events and then either saves, or not - based on the return values of the valididation on save events.

Best Regards,
Stefan

0 Kudos

Hello Stefan,

The problem is in the first run if the user has en error the code is executed but not save and there I created a new or update a record in other BO, when the user solve the error I have repeated records because the code is executed again.

Thanks

sunil1101
Advisor
Advisor
0 Kudos

Hi

You main issue is you dont want to save duplicate records in other BO. Is it?

If yes, then you should adjust your beforesave logic so it should not create repeated records,

As pradeep said you should read status in before save

If(status == release){

OtherBO.Create(boElements);

}

I have doubt about sequence of execution if first release action exectuted and then beforeSave it should serve the purpose.

Regads

Sunil

0 Kudos

Hello Sunil,

I already do that, but although an error occurs the status is == release.

Regards

sunil1101
Advisor
Advisor
0 Kudos

Hi

You should check some other condition to stop exectuing update other BO's records in case of first object does not save succesfully.

Did you tried using Action validation, check the which nodes is responsible for such error and write a validation logic in Action Validation(available for XBO only).

Regards

Sunil

0 Kudos

Hi,

I only have the OnSave validation action, this one doesn't works in this case.

Thanks.

former_member186648
Active Contributor
0 Kudos

Hi,

BeforeSave event will be executed always.

May be for your usecase, you could read Release status attribute on the BO to see if the it's released in the BeforeSave event.

Thanks, Pradeep.

0 Kudos

Hi Pradeep,

I read the status and is released although the document has errors.

Thanks

former_member186648
Active Contributor
0 Kudos

Could you check for negative stock in BeforeSave event
, if yes, you could place your logic based on this condition.

Thanks, Pradeep.

Former Member
0 Kudos

Hello Sebastian,

Even if your code in before save is being executed it won't reflect in the BO until the save is executed. As there is a standard error message and save is failing you need not bother about it, as user will never be able to save your changes until the error is resolved.

Hope it helps.

Thanks & Regards,

Meghna

0 Kudos

Hello Meghna,

Yes you're right the user can't save until solve the error, but the code is executed and did some creation in other BO and when finally the user solve the error the system execute de code again and saved repeated record because if I do a query the first record isn't in the DataBase in this moment.

Thanks

former_member105365
Participant
0 Kudos

Hi Sebastian,

Have you tried moving the error message to the Validation On Save and see is this changes the issue?

Or you could encapsulate the error message making it only raise if the status have changed to "released"?

You could try these options.

Regards,

Thomas

0 Kudos

Hello Thomas,

I can't move my code to the OnSave action because I need to do some creations in other BO.

Thanks.