Script to only fire off Once

Before I start to write this script, is there a way to only allow a script to fire off once?  Background of the script I will create:  Need to populate the "SO DETAILS PURCHASEORDERNO" if blank with a "C" for all customers except 3 or 4, and only on lines with vendorno = "0001226".  However, I don't want the script to fire off every time an update is made to the SO, or if we delete the "C" in the POno field.  Basically, do not want the "C" to reappear if we delete it or for a legitimate POno to get overwritten by the "C".

Parents Reply Children
  • in reply to jland47

    I said you can't prevent an event script from running more than once, but what connex is suggesting is using an event trigger (column post-validate on ItemCode) that naturally will only run once per line.  After you set a line's ItemCode, it never changes.

    If your business logic can be properly applied at that point, it is an excellent idea, and easier than the checkbox.

  • in reply to Kevin M

    I simplified the script without the checkbox and it populates the purchaseorderno field with the "C", however it does it no matter the customerno, so I have something wrong there.  Also curious on if I want the "C" value to be set only if a PO is not created, the column post-validate with this script fires off right after you enter the item code, I would think we would need it to look at the field after the record was written, gives the user a chance to create a PO if needed without going and deleting the "C".

    If oSession.CompanyCode = "ROI" then
    
    nCustomerNo = ""
    nVendorno = ""
    nPOno = ""
    
    rVal = oBusObj.GetValue("CustomerNo$", nCustomerNo)
    rVal = oBusObj.GetValue("VendorNo$", nVendorNo)
    rVal = oBusObj.GetValue("PurchaseOrderNo$", nPOno)
    
    	If nCustomerNo <> "2861000" or "2303006" then
    
    		If nVendorno = "0001226" then		
    
    			If nPOno = "" then			
    			rVal = oBusObj.SetValue("PurchaseOrderNo$", "C")
    			
    			End if	
    		End if
    	End if
    End if

  • in reply to jland47

    The business process is up to you.  For a pre-write event on the detail table you'd need the checkbox for control.

    Use oHeaderObj for your GetValue on CustomerNo (since it is a header field).

    Your filter on nCustomerNo is all wrong (and I'm surprised you don't get a VBScript syntax error).  Try something like this:

    variable <> "A" and variable <> "B"