Script does not trigger in Pre-Write event

SOLVED

Hi Forum,

I have a script that populates a UDF in sales order lines from 2 UDFs in the lines after the lines are entered...

if I trigger the event as Pre-Write it doesn't do anything.. but the same script I can trigger in a field as column post-validate event and works fine...

Any ideas as to why it doesn't trigger when we click the Accept button?

Regards,

Manuel Roman

Parents
  • 0

    The pre-write and post-write events will only fire if the record has been modified. Simply loading a sales order and then clicking Accept will not trigger the events.

    If you are positive you are making changes to the record and it still does not appear to be firing, then check what other scripts you have assigned to the same event and syntax check them all. If the priority is the same, they all get placed in the same VBS Sub and will error out silently if even one of them has a syntax error. 

    It also doesn't hurt to open the Trace Window so you can see what the script engine is reporting. Every time an event is triggered, it should write to the trace window.

  • 0 in reply to David Speck

    Hi David,

    Thanks for the response...

    If it is a new Sales Order it should trigger the event correct?...

    I have a few scripts but this is the only one for the Pre-Write event.

    So if the Sales Order exists the event won't be triggered unless there is a change... that sounds ok.

    I will open the Trace Windows just to see what is doing.

    Thank you very much.

  • +1 in reply to mroman
    verified answer

    New orders should trigger the event.

    You should syntax check every script attached to the same business object as the script that appears to not be firing. If you can, you might even need to remove any other scripts to test and confirm nothing else is interfering.

    If i need to prove an experimental event will trigger, i just throw a simple oSession.AsObject(oSession.UI).MessageBox "", "Success" line or oScript.DebugPrint "Success" line (if i have an opportunity to open the trace window before it will fire, won't work on a UI post-load attached to DMAIN, for example) in a test script.

    I also avoid using "Exit Sub" in any of my scripts because of the way scripts are compiled by Sage 100.

  • 0 in reply to David Speck

    Great... Thanks for the info.

    i'll try it right now...

    Regards,

  • 0 in reply to David Speck

    I use Exit Sub often, but am very careful with script triggers / priorities to avoid the combination of scripts when compiled.  A very good tip.

  • 0 in reply to Kevin M

    You bring up a good point with setting the Priority and Exit Sub can be used with great care but i avoid it to avoid conflicts with not just my own but other potential scripters as well, while still leveraging the Priority when needed. 

  • 0 in reply to David Speck
    SUGGESTED

    Thanks David... That worked fine..!!!

    Regards,

Reply Children
No Data