Close but no cigar... And this is were I start to lose my mind.
I am getting an error 26 on the set value. It has the last key text of UDF_COLLECTIONS. I have tried removing the $, I have tried " retValue =SetValue "UDF_COLLECTIONS$", Y " (both with and without $.) In all cases I get the error 26.
I tried moving the error test right below the SetKey to see if that was the error and
Thanks in advance...
'Set collections flag in open invoice records
'Bob Osborn, ACI 2/2021
sKey = "" : SDivNo = "" : sCustNo = "" : sInvNo = "" : sInvType = ""
oBusObj.GetValue "ARDivisionNo$",sDivNo
oBusObj.GetValue "CustomerNo$", sCustNo
oBusObj.GetValue "InvoiceNo$", sInvNo
oBusObj.GetValue "InvoiceType$", sInvType
sKey = sDivNo & sCustNo & sInvNo & SInvType
retMsg = oSession.AsObject(oSession.UI).MessageBox("", sKey)
oAROpen = oSession.GetObject("AR_OpenInvoice_bus")
if oAROpen <> 0 then
Set oAROpen = oSession.AsObject(oAROpen)
else
retVal = oSession.AsObject(oSession.UI).MessageBox("", "Access to AR_OpenInvoice_bus is required for the ... script to work.")
'exit sub 'won't work in a button script unless you add sub tags yourself.
end if
retVal = oAROpen.SetKeyValue("ARDivisionNo$", SDivNo)
retVal = oAROpen.SetKeyValue("CustomerNo$", SCustNo)
retVal = oAROpen.SetKeyValue("InvoiceNo$", SInvNo)
retVal = oAROpen.SetKeyValue("InvoiceType$", SInvType)
retVal = oAROpen.SetKey()
retVal = oAROpen.SetValue("UDF_COLLECTIONS$", Y)
retVal = oAROpen.Write()
if retVal <> 1 then
sMsg = "Script Error: " & oAROpen.LastErrorMsg
retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)
end if
------------------------------
Bob Osborn
Consultant
ACI Consulting
------------------------------
Original Message:
Sent: 02-23-2021 11:23
From: Robert Osborn
Subject: Button Script issue with getobject
HI Kevin,
I am getting on the right track now. I was able to get it to run without errors but it was not writing. Adding LastErrrorMsg I found that it was not in an editable state. Writing out the SetKey values now.
Thanks very much for the assist Kevin!.
------------------------------
Bob Osborn
Consultant
ACI Consulting
------------------------------
Original Message:
Sent: 02-23-2021 10:08
From: Kevin Moyes
Subject: Button Script issue with getobject
It's always a good habit to wrap any GetObject with a permission check.oAROpen = oSession.GetObject("AR_OpenInvoice_bus")
if oAROpen <> 0 then
Set oAROpen = oSession.AsObject(oAROpen)
else
retVal = oSession.AsObject(oSession.UI).MessageBox("", "Access to AR_OpenInvoice_bus is required for the ... script to work.")
'exit sub 'won't work in a button script unless you add sub tags yourself.
end if
------------------------------
Kevin Moyes
Technical Systems Analyst
Munjal White Consulting Co.
Toronto ON
Original Message:
Sent: 02-23-2021 09:58
From: Robert Osborn
Subject: Button Script issue with getobject
Hi Kevin,
It is set to run from the server. I tend to think my syntax is wrong but I see differing information.
------------------------------
Bob Osborn
Consultant
ACI Consulting
Original Message:
Sent: 02-23-2021 09:54
From: Kevin Moyes
Subject: Button Script issue with getobject
For Advanced / Premium your button needs to be set to run from the "Server" to access business objects.
------------------------------
Kevin Moyes
Technical Systems Analyst
Munjal White Consulting Co.
Toronto ON