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

Parents
  • 0
    Just an idea
    I'm using vba in my test, but for vb.net Try, Catch, End Try could be used to test the existence of a method I think

    My test using vba in access was to call a bogus method below
    On Error GoTo no_meth
    boi_retval = boi_citem.nbogus("test")
    no_meth:
    MsgBox "Error calling method", vbCritical
  • 0 in reply to sevendogzero

    I am also using VBA, but I am not looking for a method, I am looking for the UI parameter to the NLookupTask method and the BO parameter to the NewObject method that provides possible write ability to a given table. There seems to be no way to predict it. For a particular table, I can lookup the BO given in the data dictionary, but that is sometimes read-only when I have, by chance, found a read-write BO. There must be a method to lookup a related read-write BO.

  • 0 in reply to connex
    Hi connex,

    There is a property called .SecurityAccess which has several values dealing with the permissions for the current user/role/task. In order to have create & modify rights this value would have to be greater than or equal to 6.

    Hope this helps.

    Elliott
  • 0 in reply to jepritch
    Thanks Elliott, but my main issue is how does one know which UI object to check. I thought by using the Business Object field in File Header Extensions of the Data Dictionary (i.e. AP_InvoiceHistory_bus) I could replace "_bus" with "_ui", but that often doesn't work. Also, the Business Object name found there is also not necessarily one with read-write attributes.

    In summary, given a specific table name - how does one find the associated BO and UI name that provides read-write access???
Reply Children
  • 0 in reply to connex
    Generally, for the framework code we have "tried" (keep in mind this isn't always the rule) to use the following rules:

    Table: AR_Customer
    BusObj: AR_Customer_bus
    SvcObj: AR_Customer_svc
    UIObj: AR_Customer_ui

    However, I believe the table you are trying to manipulate is one of the history tables. These tables were not designed to be modified outside of the core product itself. The _bus objects that exist for history tables were created for use with V/I originally.

    You are using the correct _Ui class, however, that selection is a read-only task and that is the problem you are encountering.

    Elliott
  • 0 in reply to jepritch

    Elliott, I've picked up this project again and NO it is not to modify history (my poor choice of sample code). I would really like to be able to determine the BO for writing to any non-history table via BOI! Any hints would be much appreciated!

  • 0 in reply to connex

    While this may not be an absolute perfect statement,  usually the business object follows the name of the file.

  • 0 in reply to connex

    I usually look in Visual Integrator.  If the table is not available for import or the field is not available in the table for import, then it is not writable via BOI either.  Or at least that has been my experience.

  • 0 in reply to TomTarget

    For example:  AP_CUSTOMER -> AP_CUSTOMER_BUS    AP_VENDOR ->AP_VENDOR_BUS

    I assume you are familiar with Web Content | Resources | File Layouts and Program Information?  I get the impression you are but I'm just covering all bases.

  • +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!!!