Creating a simple script to restrict specific GL accounts from certain users

Hi, I am trying to create a script that puts the focus back on the GL account field when specific GL accounts are selected by user. So, when a user enters a GL account with a UDF_RESTRICTED value of Y, then Sage will focus back on the GL account and not allow the user to enter the specified account. Here is my script. I've tried several options and none has worked so far.

If oSession.CompanyCode = "CMH" Then
if oSession.UserCode = "TIM" Then

Restricted = ""

'********************GET STATUS*****************************
RetVal = oBusObj.GetValue("UDF_RESTRICTED$",Restricted)


if Restricted = "Y" then
retMsg = oSession.AsObject(oSession.UI).MessageBox("Restricted " & Restricted)

retVal = oscript.SetError("Restricted Account")

End If

End If
End if 'Company check

Parents Reply
  • 0 in reply to DebraGarcia

    SetError only works on Pre- type events, and will do nothing for a Post Read trigger.

    For blocking the restricted accounts from being opened in GL Account Maintenance, try to invoke the Cancel button (...or OK button if in Account Inquiry).

    You might want to add a role check so someone can maintain the settings for those accounts.

Children