Changing Counter Sales Check Box - Directive

Hi there,

I am having some difficulty surrounding checking the “Counter Sale” check box on Sales Order Entry. I have created a Method Directive BPM that sets CounterSale = True when a particular customer is set within the order header.

I note that when the check box is ticked via the UI the tabs for Lines and Releases is removed from the UI, when the check box is ticked via the BPM using “Set Field” the tabs remain.

Having completed a trace it appears that the business object that is called via the GUI is SalesOrderImpl.ChangeCounterSale.

Could anyone point me in the direction of how to invoke this routine to resolve my problem?

What Object is your Method Directive on?
Is it Pre or Post?
There maybe a UI element that is calling the SalesOrder.ChangeCounterSale.

Hi Rick,

Thank you for the response - this is a Post Processing Directive.

Ok, but what Method is the Post Proc Directive on?

I would offer that there is more that goes on when a user checks that checkbox. You will need to create the same logic in the BPM that the system performs when you check that box.

Thank you for the responses - the Post Proc Directive is on the SalesOrder.ChangeCustomer method.

Your responses have prompted my thought processes to kick in.

That might be too early.
I recommend that you disable your BPM and then run a trace of the following:
Create Sales Order
Enter Customer
Enable the counter Sale checkbox.
Don’t save in between.
See what Methods are being called… I suspect that the Order Number first needs to exist before the Counter Sale value can be set, so what you might see in the trace is that SalesOrder.Update or MasterUpdate is called before the SalesOrder.ChangeCounterSale is called. If that is the case then you will need your BPM to be on the Update or MasterUpdate, with a criteria of 'when CustomerNum is changed from Any to Another.

I did a quick test of just updating the Countersale field in a BPM, and it does show on the form. But the changes to the form (Hiding the Line and Release tabs), don’t take place. But upon refreshing the form, those two tabs do indeed become hidden. So this might require a UI customization to hide/show those tabs, on a change of the CounterSale checkbox state.

Thank you ckrusen.

I’ll go down the customisation route!

here is the bpm you have to go.

image

Erp.SalesOrder.GetNewOrderHed

var ttOrderHedRow = ds.OrderHed.Where(O => O.Added()).FirstOrDefault();
if(ttOrderHedRow != null)
{   
  ttOrderHedRow.CounterSale = true; 
}
2 Likes