SO Ship To Code Script

I created a script in Sales Order entry to fire once the ship to code is selected.  The script is firing once the customer is selected instead of when the ship to cod is selected.  Does anyone have any ideas as to why the script is firing when I select the customer?

 

Sage 100 Advanced 2017 5.40.1.0

Script is created on Sales Order Header

Event = Column post validate

Field = ShipToCode

 

For testing I used the following script

retVal=oSession.AsObject(oSession.UI).MessageBox("HI")

 

The AR customer doesn’t have the Primary Ship To code assigned.  

Any Ideas as to why it's doing this?

Thank you

  • 0
    My initial theory would be that the process of initializing the sales order header results in the ship to code being set (even if it is blank) which then trips the event for column post validate.

    I'm going to make some wild guesses here. Hopefully one will work.

    Check oBusObj.EditState to decide whether to continue processing the script. 0=no record in memory, 1=existing record, 2 = new record. Do not process initially if result is 2?

    Try event column pre-validate?


    So what are you trying to do with the script?
  • 0 in reply to TomTarget
    I will try and let you know the results. I am a little slow at this as I am still learning how.

    Script Scope:
    A customer memo code was created to reflect the same code as the ship to code. There are specific shipping notes for each ship to code. So if the ship to code matches the memo code then display the AR memo text.

    The Memo Maintenance has the feature to display but if I have 5 or more ship to codes I don't want all of those memo notes to display when creating a sales order.
  • 0 in reply to mmneal
    Seems to me that your logic of if the memo code matches the ship to code would work?

    When the order record initializes and sets the ship to code to blank or whatever the default is, your script could say stop execution if the ship to code is blank or doesn't match an existing memo. In this case it doesn't make any difference if it fires off.
  • 0 in reply to TomTarget
    I tested using the pre-validate and that worked. Now the only issue I am having is I get no data. I will continue to test.