Sage 100

 View Only
  • 1.  Help with Lines Loop script

    Posted 10-13-2020 13:25
      |   view attached

    I am working on the attached SO_SalesOrderHeader Table Post-Read script to loop through all lines of an existing quote and determine whether any of the lines are subject to a promotional unit cost based on current CI_Item UDF values (oItemSale function). My loop function will go to through all lines and show me the values for each oLines.GetValue field as expected, but I will only get the very first line's CI_Item UDF values and then nothing related to the UDFs after that. How can I get the script to make that connection out to the item table on every item pass? Any suggestions would be appreciated. Thanks!



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

    Attachment(s)

    txt
    Loop Script Sample.txt   2 KB 1 version


  • 2.  RE: Help with Lines Loop script

    Posted 10-14-2020 00:30
    Hi Amber!
    Have you tried adding a "find" statement after you establish connection to oItemSale? I'd expect to see

    retval = oItemSale.Find(sItemCode)

    right after you set oItemSale. At the very least you can throw a debugging line in there after the find statement to confirm that it is actually locating the right item code for each line.

    ------------------------------
    Kate Krueger
    Business Applications Manager
    Eide Bailly, Inc.
    Denver CO
    970-692-5113
    ------------------------------



  • 3.  RE: Help with Lines Loop script

    Posted 10-14-2020 01:15
    Edited by Alnoor Cassim 10-14-2020 01:17

    @Amber Prayfrock - What Kate said! She also uses a lot of oScript.DebugPrint() in her code which would help you here.
    Also it appears like when you do:

    if Not(IsObject(oItemSale)) then
    	set oItemSale = oLines.AsObject(oLines.GetChildHandle("ItemCode"))

    all the code below the set oItemSale through the End If would only run once because oItemSale is an object by the time it enters the 2nd iteration of the loop. 
    Ergo one way to deal is make the stmt inline like this:

    if Not(IsObject(oItemSale)) then set oItemSale = oLines.AsObject(oLines.GetChildHandle("ItemCode"))
    'also comment out the End If below the oLines.Write() like this:
    'end if

    Alternatively you could omit the If/Then:

    set oItemSale = oLines.AsObject(oLines.GetChildHandle("ItemCode"))
    'also comment out the End If below the oLines.Write() like this:
    'end if

    Hope that helps.



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

    Email: alnoor@asifocus.com
    Ph: 949-689-9887
    Orange County, CA
    ------------------------------



  • 4.  RE: Help with Lines Loop script

    Posted 10-14-2020 07:40
    Thank you to Kate and Alnoor for your suggestions! I will make those changes today. I had changed to GetChildHandle from GetObject because the connection was failing for non-administrator users, for some reason, but I didn't realize I wasn't using it properly when looping through lines.

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



  • 5.  RE: Help with Lines Loop script

    Posted 10-14-2020 11:25
    You can also try the time-saving prefix... (which doesn't always work, but it's worth a test).

    retVal = oLines.GetValue("Item.ItemCodeDesc$", tmpItemDesc)



    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------