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
  • Why couldn't you use a Column-Post Validate event on the ItemCode field to fill the PO No. field for your conditions. It would only fire once per ItemCode and not when otherwise changing the line. 

  • in reply to connex

    Column Post Validate on ItemCode should work if on a version that allows selecting it (older versions didn't but I think 2020+ does in a detail script).

    A table Post Read event filtered by oBusObj.EditState = 2 also works and once the record is saved, the EditState will be equal to 1.

    Another event could be the Set Default Values one, I haven't used it much but it is supposed to run when default values are being set by the business object on new records.

  • in reply to David_Speck

    Column Post-Validate is in every version since script events were introduced in 2010 with version 4.40. I think it is your safest bet because any event that precedes setting the ItemCode will cause the PO number field to be cleared.

Reply
  • in reply to David_Speck

    Column Post-Validate is in every version since script events were introduced in 2010 with version 4.40. I think it is your safest bet because any event that precedes setting the ItemCode will cause the PO number field to be cleared.

Children
  • in reply to connex

    The event existed since 4.4 but in certain tables, certain columns were not selectable on column events.  I seem to recall at one point, the ItemCode column could not be selected on detail tables.  I can't recall what version was the last version I saw this on though, I did just check my 2018 install and it can be selected so it may have been corrected in 2018 or maybe 2017.