Are there properties somewhere that indicate whether a BO is writable? Can a UI object name be found for a given BO?

SOLVED


I have tested that having a '_bus' entry in the Data Dictionary (DD) maintenance 'Business Object' field doesn't mean the table is writable.

For example: 'AP_InvoiceHistoryHeader' has 'AP_InvoiceHistory_bus' shown in the DD as its Business Object, but after successful nSetKeyValue (using InvoiceNo & HeaderSeqNo), nSetKey and nSetValue using that BO - causes an nWrite returns a zero! (i.e. read only - see sample program below).

How do I tell (preferably programmatically) which business objects are writable and what their UI object names are for use with nSetProgram and nLookupTask respectively?

Dim oSS: Dim oScript: Dim oBus
Dim retVal : retVal = 0
Dim sCommentWas : sCommentWas = ""

Set oScript = CreateObject("ProvideX.Script")
oScript.Init ("C:\Sage\Sage 100 Standard ERP\MAS90\Home")
Set oSS = oScript.NewObject("SY_Session")
retVal = oSS.nLogon()
retVal = oSS.nSetUser("user", "password")
retVal = oSS.nSetCompany("ABC")

retVal = oSS.nSetProgram(oSS.NlookupTask("AP_InvoiceHistory_ui"))

Set oBus = oScript.NewObject("AP_InvoiceHistory_bus", oSS)

retVal = oBus.nSetKeyValue("InvoiceNo$", "1050190")   'retVal = 1
retVal = oBus.nSetKeyValue("HeaderSeqNo$", "000000")  'retVal = 1
retVal = oBus.nSetKey()                               'retVal = 1
sCommentWas = ""
retVal = oBus.nGetValue("Comment$", sCommentWas)      'retVal = 1
retVal = oBus.nSetValue("Comment$", "Testing")        'retVal = 1
retVal = oBus.nWrite()                                'retVal = 0

  • +1 in reply to connex
    verified answer

    Hey Dan - Well this info is in the dictionary and if using File Layouts, after you find your table then in the top left look for "Bus Obj:" then can see the different _Bus and _Upd classes. Some are obvious such as SO_InvoiceHeader belonging to SO_Invoice_bus. But if your table is say SO_InvoiceTierDistribution it correctly says  SO_InvoiceTierDistribution_bus but in your BOI code most likely you will not have instantiated it directly. It's more likely you started at the Header (oInvc let's say), then referenced the Lines (oLines), then referenced the Distribution object as a child of oLines : 

    rVal = oInvc.oLines.oDistribution.nSetKeyValue("InvoiceNo$", sInvoiceNo) 'etc etc

    The point is between dictionary, File Layouts, and Windows Explorer you can get the immediate _Bus but depending on the table it may not be the way you reference it.

  • 0 in reply to Alnoor

    Great information Alnoor! Thank you!!!

  • 0

    Did you check what error code is returned from the write?  To write to AP Invoice History iou must have written at least one line (this table is the header of a header lines relationship) or if sourced from purchase order a value in freight or prepayment.