Need help with a script to prevent A/P Invoice Data Entry line entry...

SOLVED

When a certain G/L number is entered in A/P Invoice Data Entry, I would like to not allow the entry to be added to the Lines screen if the job number is missing.

Any help with this script would be greatly appreciated.  If I cannot prevent the entry of the line, a pop-up message would be ok, too.

Thanks in advance.

  • 0

    Hi  ,

    You should be able to do a pre-write script on the AP_InvoiceDetail business object.  I just did a quick and dirty one below, it would need more error checking, but I think kind of gets what you want.  It does pop a message however.  I think something like this should work.

    jobNo = ""
    glAcct = "" : glAcctKey = ""
    retVal = 0
    
    retVal = oBusObj.GetValue("AccountKey$", glAcctKey)
    retVal = oBusObj.GetValue("JobNo$", jobNo)
    
    Set oGLAcct = oSession.AsObject(oBusObj.GetChildHandle("AccountKey"))
    if oGLAcct.Find(glAcctKey) then
    	retVal = oGLAcct.GetValue("Account$", glAcct)
    
    	if glAcct="101-00-00" then
    		if jobNo="" then
    			retVal = oScript.SetError("Missing Job for this Account: " + glAcct)
    		end if
    	end if
    end if

    Hope this helps

    Elliott

  • +1 in reply to jepritch
    verified answer

    We do this with a similar script to Elliott's but use a UDF checkbox in GL_Account to control which accounts need a job#... and potential Role filter to allow blanks...

  • 0 in reply to jepritch

    Thanks, I'll give it a try.