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
  • 0

    Wrap your whole script inside an if statement.  For example:

    if oSession.CompanyCode = "TST" then

    ...

    end if

  • 0 in reply to Kevin M

    Thanks but the script is invoked, right?  In other words the script will still run in TST which is what I want to avoid.  Imagine a Company Code on the following screen so that I could control which Company invokes the script.  Does anyone know how to that?

  • 0 in reply to ssafm

    @ssafm

    There is no way to turn off an individual script from being invoked for a company.  You can turn scripting off for the entire company in Company Maintenance however.  

    Library Master/Company Maintenance

    Select your company code and go to the "2. Preferences" tab and un-check the "Allow External Access".  This will turn off all scripts for the entire company. 

    Not sure if that's what you want to do or not.  Otherwise, what Kevin is proposing is the recommendation for not executing the script logic for a specific company.

    E

Reply
  • 0 in reply to ssafm

    @ssafm

    There is no way to turn off an individual script from being invoked for a company.  You can turn scripting off for the entire company in Company Maintenance however.  

    Library Master/Company Maintenance

    Select your company code and go to the "2. Preferences" tab and un-check the "Allow External Access".  This will turn off all scripts for the entire company. 

    Not sure if that's what you want to do or not.  Otherwise, what Kevin is proposing is the recommendation for not executing the script logic for a specific company.

    E

Children
No Data