Script not triggering message

SUGGESTED

Hi 

I wrote a simple script to trigger a message on the Sales Order Details Line when the Unit Cost is greater than the Unit Price but for some reasons, the message is not popping up. I set the event trigger to Post Column on QtyOrdered but when I enter the QtyOrdered on the line item, nothing pops up.

Any help? Here's my script.

if oSession.CompanyCode = "TTT" then 


Cost = 0
Price = 0

retVAL =oBusObj.GetValue("UnitCost",Cost)
retVAL =oBusObj.GetValue("UnitPrice",Price)

if Cost > Price then

retVal = oScript.SetError("WARNING: CANNOT USE THIS ITEM! The Item Cost is less than the Item Unit Price.")

end if

end if

Parents Reply Children
  • 0 in reply to BigLouie

    @ BigLouie - Yes, message box is showing the message but i'm trying to show a script error that will prevent the user from continuing.

    @Kent Mackall - I'm running the script in TTT. We want the message to trigger when a change is made on the Unit Cost on Sales order line item. Regardless of the item valuation, we are trying to prevent a sale when the cost is more than the unit price.

    @W Jezewski - I tried oScript.SetError on Pre-Validate event but that didn't work too. 

  • 0 in reply to tobitimac

    Greetings,

    Good point by W Jezewski about oScript.SetError and Pre-Validate.  

    Have you put message boxes in the script to test

    A) That the script is actually executing

    B) That the values of cost and price being set are such that the message will display.

    Thanks,

    Kent

  • 0 in reply to Kent Mackall

    Kent notice where he says to me that the message box is working but he is trying to stop the user from continuing.  I remember Steve posting a script once that did that.

  • 0 in reply to BigLouie

    I did notice that after my response and I was doing some testing on my system.  If the message is displaying in the Pre-Validate as an oScript.SetError then I am not sure why processing would continue.

    I am testing on Sage 100 2014 in ABC Demo Data Company using a new inventory item I set up as a standard cost item with a cost of $1000 and a Price of $0. In my testing, the behavior is as expected.  The warning message displays, the Quantity ordered is zero'd out and focus is set back to the Ordered column.

    Thanks,

    Kent

  • 0 in reply to Kent Mackall

    @ BigLouie,  @Kent Mackall and @W Jezewski.

    Thank you so much guys. I don't know why the warning won't pop up either. I have informed the client and they are settling for just the messagebox.

    I guess that's good enough for now. Thanks for your prompt responses and efforts.  

  • 0 in reply to tobitimac

    sometimes the .SetWarning() will not execute because of logic in Sage's validation that may turn off the warning.  Safest play here is to go with the message box that you are already implementing.

    E