cancel
Showing results for 
Search instead for 
Did you mean: 

After Modify event in salesorder

resmi_v
Participant
0 Kudos

Dear Experts,

How can I check from code if the user has only edited the sales order item node and not the save is fired from after modify event?

Iam using Event after modify .But this event is fired in all cases including edit , save , release , etc... As I need to apply my logic in Event after modify only on the time user changes the sales order and not on other actions.

How is this possible.

Thanks ,

Resmi

Accepted Solutions (0)

Answers (2)

Answers (2)

ludger_bunger
Participant
0 Kudos

Hi Resmi,

From what I understood, you like to know whether an business object has been modified but not yet saved.

I do not see a way how to distinguish modifications triggered immediately prior to saves from others.

So maybe what you intend to achieve can be reached in a different way?

In order to be able to give some better suggestions, could you maybe elaborate on what your use case is without already having a specific way of implementation in mind?

Best regards,

Ludger

resmi_v
Participant
0 Kudos

HI,

Below is my scenario:

I have extended sales order item node to have a new discount field.Total of these discounts will be added to Sales order discount .

This item discount is calculated based on some rules (depends on product id, weight, account etc...). So the code is added in Event After modify.

We need to run this rules at every step till its approved if any new item is added or modified.

Now the issue is When I click on button Submit -> Release Order it says the message 'Changing data not possible; data is read-only' .

I know the reason as event after modify is trying to change a released item node which system doesn't allow.

But some way I need to figure out the solution .So what I thought is if user does a release ,approve etc, the code inside the AfterModify event should not execute. That is the reason I was asking by any way with Status I can accomplish this.

Any help .

Thanks,

Resmi

former_member186648
Active Contributor
0 Kudos

Hi Resmi,

You should check SalesOrder status field value in the AfterModify event , if it is not Released do the calculation.

Thanks, Pradeep.

resmi_v
Participant
0 Kudos

Dear Pradeep,

Thanks for the suggestion.This helped after the SO is released.

But for the scenario when SO is in preparation and I clicked on submit ->Release status is not yet released, the After modify event is fired.I need to identify a status to check if this aftermodify event is fired on click of Submit->Release.

This is creating a big show stopper for us to continue.

Thanks,

Resmi

former_member186648
Active Contributor
0 Kudos

Hi Resmi,

Call SalesOrder.Retrieve method and see if the status is Released.
Because Retrieve fetches data from the buffer, and you are in AfterModify ,so the buffer should already contain status as Released if Action Release is executed.

Thanks, Pradeep.

Former Member
0 Kudos

Hello Resmi,

Try to implement your code in Sales Order > Item > beforeSave event to isolate it. But any modification on the item may trigger Sales order events as well.

Best regards,

Alexandre.

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Resmi,

There are 3 events

  • AfterLoading
    which is triggered after evey change of the resp. node (even the load from the database) to calculate any transient (and only these) elements
  • AfterModify
    which is triggered after evey change for the resp. node to modify any othe rthan transient elements
  • BeforeSave
    which is triggered just before the save happens

HTH,

   Horst