Script that DOES NOT RUN per Company

I have the following script that pops up a message in Company Code HMC for users other than TAG when a certain UD is populated.  Works fine....

retVal = 0
Set oUI = oSession.AsObject(oSession.UI)
TRANS = ""
USER = ""
COMPANYCODE = ""
retVal = oBusObj.GetValue("UDF_TRANSMITTED_TO_WAREHOUSE$", TRANS)
USER = oSession.UserCode
COMPANYCODE = oSession.CompanyCode
If USER <> "TAG" THEN
If COMPANYCODE = "HMC" THEN
If TRANS= "Y" THEN
  sMsg = "WARNING: CANNOT CHANGE!  This line has already been transmitted."
  retVal = oScript.SetError(sMsg)
End If
End If
End If
...my question involves when the script is invoked.  I went into User-Defined Field and Table Maintenance, selected the User-Defined Scripts button on the right and "told" Sage 100 when to run the script.  However, I do not want the script to run at all in a certain Company Code.  Is this even possible?  I know I set the script above to only perform in HMC however it is still invoked in other Company Codes and I want to prevent that.  In other words, in Company Code TST I do not get the Message from the script but I am sure the script is still invoked.
Thanks!
Parents Reply
  • 0 in reply to Kevin M

    Generally speaking I would agree with you Kevin,  however I can imagine that it could slow down processing because it still has to walk through the script from beginning to end even if it skips executing statements?   I've never done a test to that point so I don't know if it could make a significant difference or not.

Children
  • 0 in reply to TomTarget

    That is why I put the company filter as the first non-comment line in the script.  If that is false, it just skips to the associated end if, and I've never noticed a performance hit using this method.

  • 0 in reply to Kevin M

    I do exactly the same thing.  Since it is not truly a "compiled" code,  I assume it still has to at least "read" down the script to find the END IF.   In most cases the code won't be long enough to have any impact on performance.  I once did a script that was several pages long but it pretty much ran infrequently so it really wouldn't have made a dramatic difference.  I have often wondered it that script was run more frequently whether there would have been a noticeable performance hit.

    I also do a similar if for the user so when I am initially installing it on a client system I can make it run only for me so that I can do final testing in the client's environment.