User Defined Scripts to populate a UDF

SOLVED

I'm creating a script to auto-populate an SO_Detail UDF (UDF_SHIP_REF1) so that I can pass data to StarShip.  The goal is to concatenate the item number with the Customer PO Number (i.e. "3131000 / 123456789" )

I have developed a more detailed script (at the bottom of this post), but it doesn't work.

In trying to build on any success, I stripped out everything to just get a single bit of data into the UDF.  Again, without success

Any Ideas where I'm off?

STRIPPED SCRIPT

dim ref1

ref1 = ""

ref1 = "Testing of UD scripting"

retval = oBusObj.SetValue("UDF_SHIP_REF1$", ref1) 'into so_salesorderdetail.

DETAILED SCRIPT

dim retVal

dim item
dim po
dim ref1

item = ""
po = ""
ref1 = ""

retVal = oBusObj.GetValue("ItemCode$", item) ' from so_salesorderdetail.

oBusObj.ReadAdditional "SONumber"
oSession.AsObject(oBusObj.GetChildHandle("SONumber")).GetValue "CustomerPONo$", po

'ref1 = item & " / " & po
ref1 = "Testing of UD scripting"

retval = oBusObj.SetValue("UDF_SHIP_REF1$", ref1) 'to so_salesorderdetail.

Parents
  • 0

    What event are you using?  Adding the script to UDS maintenance doesn't make it active.  You have to then attach the script to an event for it to work.

    Edit: I misread the OP... I see CPV on QuantityOrdered.  How are you testing?  If your UDF is in the upper grid, it might be working, but simply not refreshing what you see on screen until you click off Lines and back.

    For the CustomerPONo, use retVal = oHeaderObj.GetValue(... instead of your child handle.

  • 0 in reply to Kevin M

    I’m testing by pulling SO lines data (including) UDF into an Excel workbook. 

    I think that’s it, I didn’t put the UDF on the grid. 

    I will then let y’all know. I feel like a big dummy. 

  • 0 in reply to Rodney Roberts

    I put the UDF into the Grid of SO Data Entry.

    I am able to type data into the field and retrieve it.

    I am still NOT getting any results from the simple script.

    I have clicked away from the lines tab, then back with no change.

    I'm stumped.

  • 0 in reply to Rodney Roberts

    I re-compiled and am getting expected results.  Many thanks.

    I let you know how the more advanced script goes (or not).

  • 0 in reply to Rodney Roberts

    I'm almost getting exactly what I'm after.  Thanks to each of you.

    I'm still missing the Item Number and the ARCustDiv.  I think I just don't have the name of the data as used in the Business Object.  How can I find that info?

    The complete script is below.

    Complete Script

    dim retVal

    dim item
    dim po
    dim so_num
    dim div
    dim ref1
    dim ref2

    item = ""
    po = ""
    so_num = ""
    div = ""
    ref1 = ""
    ref2 = ""

    retVal = oBusObj.GetValue("ItemNo$", item)

    retVal = oHeaderObj.GetValue("CustomerPONo$", po)

    retVal = oHeaderObj.GetValue("SalesOrderNo$", so_num)

    retVal = oHeaderObj.GetValue("ARCustDiv$", div)

    ref1 = item & " / " & po
    'ref1 = "Testing of UD scripting for Ref1"

    ref2 = so_num & " / " & div(1,1) & "0"
    'ref2 = "Testing of UD scripting for Ref2"

    retVal = oBusObj.SetValue("UDF_SHIP_REF1$", ref1)
    retVal = oBusObj.SetValue("UDF_SHIP_REF2$", ref2)

Reply
  • 0 in reply to Rodney Roberts

    I'm almost getting exactly what I'm after.  Thanks to each of you.

    I'm still missing the Item Number and the ARCustDiv.  I think I just don't have the name of the data as used in the Business Object.  How can I find that info?

    The complete script is below.

    Complete Script

    dim retVal

    dim item
    dim po
    dim so_num
    dim div
    dim ref1
    dim ref2

    item = ""
    po = ""
    so_num = ""
    div = ""
    ref1 = ""
    ref2 = ""

    retVal = oBusObj.GetValue("ItemNo$", item)

    retVal = oHeaderObj.GetValue("CustomerPONo$", po)

    retVal = oHeaderObj.GetValue("SalesOrderNo$", so_num)

    retVal = oHeaderObj.GetValue("ARCustDiv$", div)

    ref1 = item & " / " & po
    'ref1 = "Testing of UD scripting for Ref1"

    ref2 = so_num & " / " & div(1,1) & "0"
    'ref2 = "Testing of UD scripting for Ref2"

    retVal = oBusObj.SetValue("UDF_SHIP_REF1$", ref1)
    retVal = oBusObj.SetValue("UDF_SHIP_REF2$", ref2)

Children