problem with code

mkpjsrmkpjsr Member Posts: 587
Hi all,

I am creating a report to show item's inventory based on location, here i want to calculate the total of quantity for items under two locations called "Main Store" and "Production".
so i have written the following code but its calculating the total for all locations.

My report is having one data item called "Item" and i have written the code under OnAfterGetRecord trigger.

SETFILTER("Location Filter",'%1|%2','MAIN STORE','PRODUCTION');
CALCFIELDS(Inventory);
TotalQty := Inventory;

what is wrong with the code.

Answers

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    This works for me in the demo W1 NAV 5.0 SP1 company:
    GET('1968-W');
    SETFILTER("Location Filter",'%1|%2','GREEN','RED');
    CALCFIELDS(Inventory);
    MESSAGE('%1',Inventory)
    
    Result is 8.

    GET('1968-W');
    SETFILTER("Location Filter",'%1|%2','GREEN','YELLOW');
    CALCFIELDS(Inventory);
    MESSAGE('%1',Inventory)
    
    Result is 14.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • GAPGAP Member Posts: 2
    Try Writing the code Setfilter on predataitem trigger
    the rest on aftergetrecord trigger.
  • veerendraveerendra Member Posts: 66
    Is the problem fixed with the solution provided by GAP :thumbsup:
    Veerendra Ch.
    http://midynav.blogspot.com/ (Microsoft Dynamics Navision)
  • mkpjsrmkpjsr Member Posts: 587
    veerendra wrote:
    Is the problem fixed with the solution provided by GAP :thumbsup:

    The code is working fine under OnAfterGetRecord Trigger also,

    actually i had written SETRANGE("Location Filter") after SETFILTER thats why it was not working

    thanx u all for the reply
Sign In or Register to comment.