Scripting

Expand all | Collapse all

I'm in a Cash Receipts header script and want to g

Kevin Moyes

Kevin Moyes03-27-2018 14:18

Kevin Moyes

Kevin Moyes03-27-2018 14:33

  • 1.  I'm in a Cash Receipts header script and want to g

    Posted 03-27-2018 13:36
    I'm in a Cash Receipts header script and want to get a value from within the deposit record. I know I can open a new object and look up the DepositNo but I'm wondering if there is a ChildHandle shortcut of some sort. Perhaps the deposit is the ""header"" of AR_CashReceiptsHeader (not a child)? This fails (with a missing object error, and I am assuming it is because the GetChildHandle doesn't work for DepositNo): oDeposit = oBusObj.GetChildHandle(""DepositNo"") if oDeposit <> 0 then Set oDeposit = oBusObj.AsObject(oDeposit) end if retVal = oDeposit.GetValue(""UDF_LOCATION$"", sLocation) If anyone is curious, the end goal is to take a UDF from the AR_CashReceiptsDeposit and flow that through to GL_DetailPosting.


  • 2.  RE: I'm in a Cash Receipts header script and want to g

    Posted 03-27-2018 13:43
    Have you tried retVal = oBusObj.GetValue(""Deposit.UDF_YOUR_UDF_NAME$"", sYourVariableName)


  • 3.  RE: I'm in a Cash Receipts header script and want to g

    Posted 03-27-2018 13:53
    Thanks for the suggestion, but that is not returning a value. This customer is on v2016 (if it matters), and I've only seen that kind of shortcut for ""ProdLine."", ""Item."" and ""Header."", (not ""Deposit."").


  • 4.  RE: I'm in a Cash Receipts header script and want to g

    Posted 03-27-2018 14:01
    i did a dump from the command window launched from the UI and saw those values prefixed with Deposit. so i thought it might be worth a shot, after posting, i did another dump from a post read script and could not locate any variables prefixed with Deposit. Seems like they are only populated in the UI scripts. What i did find in the post read dump however was a handle to the AR_CashReceiptsDeposit_bus object via the variable coDeposit. You could get this to your script by using the following. _____________________________ nDepositBusObj = 0 : nDepositBusObj = oScript.Evaluate(""coDesposit"") if nDepositBusObj > 0 then set oDepositBusObj = oBusObj.AsObject(nDepositBusObj) sYourVariableName = """" : retVal = oDepositBusObj.GetValue(""UDF_YOUR_UDF_NAME$"", sYourVariableName) set oDepositBusObj = nothing end if _____________________________


  • 5.  RE: I'm in a Cash Receipts header script and want to g

    Posted 03-27-2018 14:09
    Thanks again David. I tried the oScript.Evaluate but that gave me another missing object error. I just settled for brute force and created an object. retVal = 0 : retFind = 0 sLocation = """" : sDeposit = """" oDeposit = oSession.GetObject(""AR_CashReceiptsDeposit_bus"") if oDeposit <> 0 then Set oDeposit = oSession.AsObject(oDeposit) else retVal = oSession.AsObject(oSession.UI).MessageBox("""", ""Access to AR_CashReceiptsDeposit_bus is required for the ... script to work."") exit sub end if retVal = oBusObj.GetValue(""DepositNo$"", sDeposit) retFind = oDeposit.Find(sDeposit) retVal = oDeposit.GetValue(""UDF_LOCATION$"", sLocation) 'other stuff set oDeposit = nothing


  • 6.  RE: I'm in a Cash Receipts header script and want to g

    Posted 03-27-2018 14:13
      |   view attached
    Update, a little more digging and i found the property DepositObject available in the cash receipts header UDS via the oBusObj object actually points to the same object handle in the coDeposit variable even though my v2016 file layouts says DepositObject points to the AR_CashReceiptsDetail_bus. So you should be able to do the following. ____________________________ if oBusObj.DepositObject > 0 then set oDepositBusObj = oBusObj.AsObject(oBusObj.DepositObject) sYourVariableName = """" : retVal = oDepositBusObj.GetValue(""UDF_YOUR_UDF_NAME$"", sYourVariableName) set oDepositBusObj = nothing end if ____________________________


  • 7.  RE: I'm in a Cash Receipts header script and want to g

    Posted 03-27-2018 14:18
    Oh I like that much better!


  • 8.  RE: I'm in a Cash Receipts header script and want to g

    Posted 03-27-2018 14:19
    It also has the added benefit of being the object in memory already on the deposit record you are after so no need to do a Find operation.


  • 9.  RE: I'm in a Cash Receipts header script and want to g

    Posted 03-27-2018 14:26
    I agree. It makes for a better script. retVal = 0 : retFind = 0 sLocation = """" : sDeposit = """" if oBusObj.DepositObject > 0 then set oDeposit = oBusObj.AsObject(oBusObj.DepositObject) retVal = oDeposit.GetValue(""UDF_LOCATION$"", sLocation) 'other stuff set oDeposit = nothing end if


  • 10.  RE: I'm in a Cash Receipts header script and want to g

    Posted 03-27-2018 14:27
      |   view attached
    On another note, are you aware of the SY_Service inheritable method GetDataSources()? You can use it with MessageBox or DebugPrint to see what fields you can use the GetChildHandle() method on. Use it like this. ______________________________ oSession.AsObject(oSession.UI).MessageBox """", """" & oBusObj.GetDataSources() ______________________________


  • 11.  RE: I'm in a Cash Receipts header script and want to g

    Posted 03-27-2018 14:33
    Thanks for the extra tip!


  • 12.  RE: I'm in a Cash Receipts header script and want to g

    Posted 03-27-2018 20:42
      |   view attached
    And just for completeness here is another way to identify the Deposits object from AR_CashReceipts_bus It's where you go into Cash Receipts Entry (after you've entered the Batch No and Deposit No). Assuming you have set your Debug=1 in the SOTA.INI, click in top left of window, choose Debugging Environment > Command Mode Window. At the Command window click on Halt. At the prompt that appears type OBJ and press Enter. From here we can tell ""DepositObject"" is the handle name (see screenshot) So like you suspected it's already there and all that's left is to explicitly Set it for VB: Set oDeposit = oBusObj.AsObject(oBusObj.**DepositObject**) _The advantage of using OBJ is you don't have to rely on the doc._ (it's also how I identified the payments object handle for you from S/O Entry when you doing a project for that client). David brings up a very nice point you don't need to Find() because we are already sitting on the Deposit key.


  • 13.  RE: I'm in a Cash Receipts header script and want to g

    Posted 03-27-2018 22:00
    One more thing for completeness. The UI version of GetDataSources() is to go to UDF Maintenance, choose the table / object, pretend to create a Business Object UDF, then hit the dropdown for Data Sources.


  • 14.  RE: I'm in a Cash Receipts header script and want to g

    Posted 03-28-2018 11:41
    Thanks Alnoor too! Knowing how to find answers is very helpful.