Skip to main content

Hello, 

I want to display a pop up message when the quantity is entered on a sales order line if a condition is met. I have the following:

protected virtual void _(Events.FieldUpdated<SOLine, SOLine.orderQty> e)
{
SOLine row = (SOLine)e.Row;
if (row == null) return;
if (row.Qty > 10000)
{
WebDialogResult res = Base.Document.Ask("Warning", "This is a large order", MessageButtons.OK);
}
}

This works, as shown below. I enter a sales order and the message appears. 

 

The problem is that the message also appears when a Sales Quote as converted to a Sales Order.
This makes sense since the SOOrderEntry is used to perform the convertion. 

Is there any way to check whether the UI is being used to enter the sales order, or to check which graph has called the SOOrderEntry graph? 

Thanks

A couple things:

1) dialog boxes have limitations, as you've discovered. If possible, it's better to set UI warnings, although they are easier to miss

2) you could check the cache status to see if the order is being inserted, since the conversion would be inserting a new order, and only show a dialog for an update; there would be complications with this as well

 


I’m agree with @darylbowman if possible it is  better to write UI warnings. In any case or for some reason, if you need to throw a popup message, you should add some conditions in addition to the existing ones (if (row.Qty > 10000)).
1.   e.ExternalCall - if true it mean field has been updated from screen mannualy
2.  !this.Base.IsCopyOrder - to skip getting same situtaion after running Copy Order action.
3.  !this.Base.IsCopyPasteContext - to skip getting same situtaion after using Copy and Past actions.


I already have UI warnings in place but I being asked to provide something which will force the user to take action - even if the action is just clicking the OK button. The UI warning are great but so easily missed.

Thanks for the feedback. 

Checking the cache status would work but the status will be the same whether the order is being converted or entered via the UI. 

Same issues with e.External, it returns the same value whether converting from a quote or entered using the UI. 

Good tips about the copy/paste - I hadn’t considered these actions. 

I’m not sure there is a good answer to this. 


Perhaps an alternative solution would be to incorporate a type of workflow. You could add a flag field to the SOLine that would be set when the value exceeds the indicated amount, which would then prevent the order from being processed (shipped, etc) until a button was clicked, which would unset the flag, allowing processing again. Similarly, perhaps an approval map could be used, with everyone allowed to approve.

Just some ideas.


I already have UI warnings in place but I being asked to provide something which will force the user to take action - even if the action is just clicking the OK button. The UI warning are great but so easily missed.

Thanks for the feedback. 

Checking the cache status would work but the status will be the same whether the order is being converted or entered via the UI. 

Same issues with e.External, it returns the same value whether converting from a quote or entered using the UI. 

Good tips about the copy/paste - I hadn’t considered these actions. 

I’m not sure there is a good answer to this. 

In addition you can try to add checking for the screenID using Base.AccessInfo.ScreenID.Replace(“.”,””)==”SO301000”. The Base.AccessInfo.ScreenID from sales quote converting process will be the same as Sales Quote screen ID


Once again, thanks for the feedback. 
I’ve attempted to use Accessinfo.ScreenID and it’s working perfectly. The adjusted code is below, the popup appears when a sales order is created in the UI, it doesn’t appear when an quote is converted to an sales order. Just what I was trying to achieve - happy days!

protected virtual void _(Events.FieldUpdated<SOLine, SOLine.orderQty> e)
{
SOLine row = (SOLine)e.Row;
if (row == null) return;
if (row.Qty > 10000 && Base.Accessinfo.ScreenID.Replace(".", "") == "SO301000")
{
WebDialogResult res = Base.Document.Ask("Warning", "This is a large order", MessageButtons.OK);
}
}

I’ll work this idea into the more complex conditions I’m checking for, and have a closer look at what else the Accessinfo object offers.

Have a lovely weekend. 


Reply