Hi all,
I'm trying to create the following process:
(1) Get packing lines and fill them in a temp table shown in a form
(2) Loop through records and calculate total weight when button is clicked
However if the button code below is executed it loops through the same amount of rows that is in the datasource but in my case the itemid is not updated.
Any idea why?
void clicked() { WHSTmpPackingLine loop = whstmppackingline_ds.getFirst(); while (loop) { info(strFmt(WHSTmpPackingLine.ItemId)); loop = WHSTmpPackingLine_ds.getNext(); } super(); }
Thank you for your tip! I understand the logic now. I'm not much of a programmer and just conquering the concepts of X++.
Hi Berthil,
As mentioned by Gunjan, you need to use info(strFmt(loop.ItemId));
Also as a best practice do not use generic variables like 'loop' instead you can create variables like WHSTmpPackingLine whsTmpPackingLineloc = whstmppackingline_ds.getFirst(); and use whsTmpPackingLineloc in your logic. such code is more readable in the future by you or anyone else.
If it's a temporary table, you can simply use a select statement:
while select whsTmpPackingLine { info(strFmt(whsTmpPackingLine.ItemId)); }
Then you can also use sum() aggregation function to calculate the total.
Try this instead for the info part -
info(strFmt(loop.ItemId));
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156