Thanks again for all of your help, David. I really appreciate the learning.
Madeline, this was the script that I ended up with that got me almost there. There appears to be something different with JobOps that won't refresh the grid like Sales Order Entry does. I have to move to another tab in Work Ticket Entry and then back to Parts in order to see the Quantity Required populated.
sItemCode = "" : nQtyReqd = 0 : nQtyReqdInc = 0 : nQtyReqdRound = 0
Set oLines = oBusObj.AsObject(oBusObj.Lines)
retVal = oLines.MoveFirst()
Do Until cBool(oLines.EOF)
retVal = oLines.GetValue("ItemCode$", sItemCode)
If Left(sItemCode,2) = "P-" Then
retVal = oLines.GetValue("QuantityOrdered", nQtyReqd)
nQtyReqdInc = nQtyReqd + .5
nQtyReqdRound = ROUND(nQtyReqdInc,0)
retVal = oLines.SetValue("QuantityShipped", nQtyReqdRound)
retVal = oLines.Write()
End If
retVal = oLines.MoveNext()
Loop
oScript.LinesAdded = -1
retVal = oScript.LoadGrid("GD_Lines")
retVal = oScript.InvokeButton("fldr.PMAIN")
'retVal = oScript.InvokeButton("fldr.PPARTS")
------------------------------
Amber Prayfrock, Blytheco
------------------------------
Original Message:
Sent: 04-30-2020 23:34
From: David Speck II
Subject: Help with scripting Qty Used to Qty Required for each JT Parts Usage line
Since this is a button script, you should be able to use the following at the end of your script.
oScript.LoadGrid "GD_Lines"oScript.LinesAdded = -1
Also, since you are updating more than just the selected line when the button is clicked, replace the oUIObj.InvokeChange method with the oLines.SetValue method. Reloading the grid should take care of making sure everything is displayed correctly.
------------------------------
David Speck II
Tennessee Software Solutions
------------------------------
Original Message:
Sent: 04-30-2020 23:09
From: Amber Prayfrock
Subject: Help with scripting Qty Used to Qty Required for each JT Parts Usage line
Thank you so much, David. Sorry that I was not clear with my need for the population of all lines. Now I understand better the order of events. I've just got to figure out the grid refresh and I should be good. Thank you again for your mentoring!
------------------------------
Amber Prayfrock, Blytheco
Original Message:
Sent: 04-30-2020 14:52
From: David Speck II
Subject: Help with scripting Qty Used to Qty Required for each JT Parts Usage line
Based on your OP, i had thought you were only trying to update the currently selected line so the script sample i included was with that in mind, you would first select the line you wanted to updated and then click the button.
If you are trying to loop through and update every line (that fits your criteria), then you need to move the InvokeChange and Write to inside of the loop and you can probably get rid of the first EditLine that was before the InvokeChange since the last EditLine is only need to make sure to pair the Lines object's key up with the grid's row that was selected when the button was clicked.
------------------------------
David Speck II
Tennessee Software Solutions
Original Message:
Sent: 04-30-2020 14:31
From: Amber Prayfrock
Subject: Help with scripting Qty Used to Qty Required for each JT Parts Usage line
@David Speck II, thank you very much for the quick response on Tuesday. I ended up with another big project yesterday so couldn't come back to this. I understand the "InvokeObject" now to write the value per line, so that is extremely helpful. But I can't seem to understand why it will not write to every one of my lines without me clicking on each line. This is what I'm seeing happen at the moment: When I first move to the Parts Usage tab, I get an "Item Code is Required" so the script is trying to write to the next blank row. If I then highlight any item row and click my button script, the Qty Shipped value from the last line on the order will write to the active line. So the script is looping and seeing all items and quantities, but it's not writing to each line before moving to the next. I attempted to mess with the order of the move and loop functions but that doesn't work either (not that I expected it to but didn't figure there was any harm in trying). This is what I currently have - please let me know if you recognize the issue:
sItemCode = "" : nQtyReqd = 0 : nQtyReqdInc = 0 : nQtyReqdRound = 0
Set oLines = oBusObj.AsObject(oBusObj.Lines)
sCurrentKey = "" : sCurrentKey = oLines.GetKey()
retVal = oLines.MoveFirst()
Do Until cBool(oLines.EOF)
retVal = oLines.GetValue("ItemCode$", sItemCode)
If Left(sItemCode,2) = "P-" Then
retVal = oLines.GetValue("QuantityOrdered", nQtyReqd)
nQtyReqdInc = nQtyReqd + .5
nQtyReqdRound = ROUND(nQtyReqdInc,0)
End If
retVal = oLines.MoveNext()
Loop
retVal = oLines.EditLine(sCurrentKey)
retVal = oUIObj.InvokeChange("QuantityShipped", nQtyReqdRound, "GD_Lines")
retVal = oLines.Write()
retVal = oLines.EditLine(sCurrentKey)
------------------------------
Amber Prayfrock, Blytheco
Original Message:
Sent: 04-29-2020 08:45
From: Madeline Stefanou
Subject: Help with scripting Qty Used to Qty Required for each JT Parts Usage line
Interesting Ask. I'm curious if you will get this to work with David's Help; as it is often requested by JobOps Clients. It could be easier than "Parts Usage"; I think. Report back if you get it to work, to satisfy my curiosity. :)
------------------------------
Madeline Stefanou
RKL eSolutions, LLC