Updating unit prices of Items from a custom list page

Hi All,

I am in need of help on this issue.

I have a custom list page that has diferent columns like Item No.,Name, Unit cost, selling unit price, Qty, VAT, Mgt Fees, Bank Charges and so on.Based on computation, selling unit price is calculated. So, With the click of a custom function from this custom list page, the unit price of the item card is updated with the same value on the selling unit price field.This is perfectly working for a single line on the custom list page when selected.I am unable to figure out how to do the same for multiple lines on the custom list page- cllciking the custom function and updating the unit price of all the items on thier cards.

Your help is sought.

Thanks.

I assume you have one to many link between customer and item, hence you have to extend you single update function to multiple line update using SETRANGE and REPEAT UNTIL function which work. If you can share the code for single update I can then extend the same code and show you how to update for multiple update.

Hi sbhatbng,

Thanks for your contribution.I have actually tried these lines of code:

CurrPage.SETSELECTIONFILTER(ProfTempLRec);
ItemGRec.SETCURRENTKEY(ItemGRec.“Profitability Code”);
ItemGRec.SETRANGE(ItemGRec.“Profitability Code”,“No.”);
ItemGRec.SETRANGE(ItemGRec.“Block Profitability Update”,FALSE);
IF ItemGRec.FINDSET THEN BEGIN
REPEAT
MESSAGE(‘PROFIT NO. %1’,ProfTempLRec.“No.”);
ItemGRec.VALIDATE(ItemGRec.“Unit Price”,“Selling Unit Price($)”);
ItemGRec.MODIFY;
MESSAGE(‘Selling price updated’);
UNTIL ItemGRec.NEXT = 0;
END;

But to my surprise, it is still updating just the item connected with the first line on the custom list page instead of all the items involved after the custom function has been clicked.

Here is how I would rewrite your code

Not sure which version of NAV you are using !!!

OnAction() //What ever trigger you are calling from.

proftemprec.copy(rec);

itemgrrec.reset;

itemgrrec.setcurrentkey(“profitability code”,"block profitablility update); // You need both of the fields in the key to sort correctly.

ItemGRec.SETRANGE"Profitability Code",proftemprec.“No.”);
ItemGRec.SETRANGE(“Block Profitability Update”,FALSE);
IF ItemGRec.FINDSET THEN BEGIN

REPEAT

if proftemprec.“selling unit price $” <> 0 then begin //To make sure you dont update a 0 unit price if item table already had a unit price.
ItemGRec.VALIDATE(“Unit Price”,proftemprec.“Selling Unit Price($)”);
ItemGRec.MODIFY;

end;
UNTIL ItemGRrec.next = 0

end;

Hope this helps.

RJ.

Hi sbhatbng,

Thanks very large for this contribution.It is really helpful.Once again, however, it is only updating the unit price of the item connected to the last line on the custom list page.Others are not just affected.

I need your help once again on this.

I am working on BC 140 using C/SIDE IDE not VSCODE Environment.

Thanks galore.

Ok, please let me know how is your proftemprec table and itemGrec linked, in other words what is the field that is common between these 2 table, also can you please put some values in your example such that I know exactly what you are trying to update. It’s a very straight forward task and should not be that complicated. I am not getting how your table link is, once you give me that you might have to just tweak the above code, its as simple as that.