Sage 100

 View Only
  • 1.  oSession.AsObject type mismatch error

    Posted 04-02-2019 16:02
    ​​#scripting

    I am having issues taking a script that was written to pass the Primary Vendor Lead Time On Exit from the Item Vendor panel in Item Maintenance to a UDF on the Main panel and recreating it to pass the Default Whse Bin On Exit from the Reorder panel to a UDF on the Main panel.  I have chopped it down to just the very first part where it makes a connection to Item Maintenance to get the Item Code and Default Warehouse of the item in question, and I still get an 'Error 88 SY_CommonUI.pvc" and Type mismatch: 'oSession.AsObject'.

    Does 'coItem' not work the same when inside the DREORDER panel than it does inside of DVENDORS, or am I way off the mark? Any guidance would be appreciated. Thank you!

    If oSecurity.TaskType = "M" and oBusObj.SecurityAccess > 0 Then

    'ResetVariables
    sRetval = "" : sItemCode = "" : sDfltWhse = "" :
    nRetval = 0 : sBinLocation = ""

    Set coItem = oSession.AsObject(oScript.Evaluate("coItem"))

    sRetval = coItem.GetValue("DefaultWarehouseCode$", sDfltWhse)
    sRetval = coItem.GetValue("ItemCode$", sItemCode)

    sMsg =  sItemCode & sDfltWhse
    r=oScript.DebugPrint(sMsg)

    End If

    ------------------------------
    Amber Prayfrock, Blytheco
    ------------------------------


  • 2.  RE: oSession.AsObject type mismatch error

    Posted 04-03-2019 00:20
    Edited by Alnoor Cassim 04-03-2019 02:45
    Let's just say these 2 panels have to be treated differently.

    When running a UI Panel OnExit or Panel PostLoad script:
    * Reference coItem to Get or Set values on CI_Item FROM Item Vendor panel (yer old script)
    * Use oBusObj to Get or Set values on CI_Item FROM Reorder Panel
    * Reference coItemWhseBus to Get or Set values on IM_ItemWarehouse FROM Reorder Panel (grid)
    * See example below for OnExit of DReorder panel.

    sDfltWhse = "" : sItemCode = "" : sReorderWhse = "" : sBinLocation = ""
    Set oIM2 = oSession.AsObject(oScript.Evaluate("coItemWhseBus"))


    'Get vals from CI_Item in the normal way

    r = oBusObj.GetValue("DefaultWarehouseCode$", sDfltWhse)
    r = oBusObj.GetValue("ItemCode$", sItemCode)

    'Get vals from IM_ItemWarehouse based on current row in the grid the cursor is sitting on

    r = oIM2.GetValue("WarehouseCode$", sReorderWhse)
    r = oIM2.GetValue("BinLocation$", sBinLocation)

    'Show vals from both CI_Item and IM_ItemWarehouse FROM DReorder panel
    sMsg = "Dflt Whse: sDfltWhse " & vbCRLF & _

          "Item No: " & sItemCode & vbCRLF & _
          "Reorder Whse: " & sReorderWhse & vbCRLF & _
          "Bin Loc: " & sBinLocation
    retMsg = oSession.AsObject(oSession.UI).MessageBox("",sMsg)

    ------------------------------
    Alnoor Cassim

    Free Agent Developer and Consultant
    CallForHelp.biz
    Email: alnoor@callforhelp.biz
    Orange County, CA
    ------------------------------



  • 3.  RE: oSession.AsObject type mismatch error

    Posted 04-03-2019 12:07
    As always, you are perfection, Alnoor :) I was able to figure out the rest needed to set the key, etc. and have it working now. Thank you so much!

    I'm still very much a noob with scripting...I don't get to practice it as much as I would like. Is there any guide available to me that lists these "co" objects, or is that more for the Intermediate/Advanced scripting class?

    ------------------------------
    Amber Prayfrock, Blytheco
    ------------------------------