User Define Script on User Define Table

SOLVED

Hi,

Below is my script to Prompt user a warning that when user entering invoice data entry, it will check a udt for blanket PO is out of fund.

I've create User Define Table to keep track of a listed PO and Billed Amount.  The script is reading invoice PO# and then Prompt if user enter more than enough.

i assigned Event- Table -Pre Totals

The issue is sometime is work and sometime i got the error message.

Can someone help me look into my script and see where is the issue.

retVal = ""
user = ""

custOrderType =""
retVal = oBusObj.GetValue("InvoiceType$", custOrderType)

if (custOrderType = "IN") Then
    'Read in PO Number and Total Sales Order Amount
    custPONumber = ""
    custNonTaxableAmt =0
    custTaxableAmt =0
    custTotal = 0
    custNumber=""
    retVal = oBusObj.GetValue("CustomerPONo$", custPONumber)
    retVal = oBusObj.GetValue("CustomerNo$", custNumber)
    retVal = oBusObj.GetValue("NonTaxableAmt", custNonTaxableAmt)
    retVal = oBusObj.GetValue("TaxableAmt", custTaxableAmt)
    custTotal = custNonTaxableAmt + custTaxableAmt
    oItemChange = 0
    count = 0
    oItemChange = oSession.GetObject("CM_UDTMaint_bus", "SO_UDT_BLANKETPO")
    if oItemChange <> 0 then
 
        SET oItemChange = oSession.AsObject(oItemChange)
        oItemChange.MoveFirst
        count = 0

        DO WHILE NOT CBool (oItemChange.EOF)
            TableCustPO = ""
            TablePOAmt = 0
            TablePOCust = ""
            TablePORemain =0
            TablePOBilled=0
            TablePOSO = 0
            reviseAmt = 0
            retVal = oItemChange.GetValue("UDF_BLANKETPONO$", TableCustPO)
            retVal = oItemChange.GetValue("UDF_BLANKETPOAMT", TablePOAmt)
            retVal = oItemChange.GetValue("UDF_BLANKETPOCUST$", TablePOCust)
            retVal = oItemChange.GetValue("UDF_BLANKETPOREMAIN", TablePORemain)
            retVal = oItemChange.GetValue("UDF_BLANKETPOBILLED", TablePOBilled)
            retVal = oItemChange.GetValue("UDF_BLANKETPOSOAMT", TablePOSO)
            if custPONumber =  TableCustPO then                                
                if custTotal >  TablePORemain then
                    retVal = oSession.AsObject(oSession.UI).MessageBox("Blanket PO is out of fund. Please get new PO or add more fund")
            
                end if
                TablePOSO = custTotal
                
                BlanketType = ""
                retVal = oItemChange.GetValue("UDF_BLKOTYPE$", BlanketType)
                If BlanketType = "Service Contract" then
                    TablePORemain = TablePOAmt - TablePOBilled - custTotalg
                else

                    TablePORemain = TablePOAmt - TablePOBilled - TablePOSO
                end if

                retVal = oItemChange.SetValue("UDF_BLANKETPOREMAIN", TablePORemain)
                retVal = oItemChange.SetValue("UDF_BLANKETPOSOAMT", TablePOSO)

                retVal = oItemChange.Write ()
                oItemChange.MoveLast
                    
            
            end if
            oItemChange.MoveNext
        LOOP
  

    end if

end if

  • +1
    verified answer

    I'm guessing you've added the UDT to the menu while you were in UDF Maintenance. By doing this, a task is added to Sy_Task which makes it subject to access via Role Maintenance. IOW, go to Role Maintenance / Tasks / Custom Office / Misc Tasks and look for your UDT there. Check that UDT box for all roles involving users that will run your script. That should do it. 

    Side Note: There is an old defect where if you have multiple UDTs seen in Role Maintenance, checking the box for the 1st one is also required regardless of whether you're using it in your script. In those cases, I usually check all the UDT boxes I see.