Filter on active record

Hi, I’m using a button with a RunObject command to export files from a purchase order to an excel sheet. I’m using following code “on push”: PurchaseHeader.SETRANGE(“No.”,PurchaseHeader.“No.”); How come this filter doesn’t work? The dataport exports all the purchase headers to excel! What am I doing wrong? Thanks!

If you use the RunObject Property of the MenuButton, the code in the OnPush-Trigger do nothing. You have to define your filters via the properties of the MenuButton. On the other hand, you can do all with the C/AL code and leave the properties empty.

Sorry, but on which property of the “Menu item” can you put the filter?

Hi, I’m afraid it can’t be done via the MenuItem properties. You’ll have to code your way out of this (press F9 and add code to the OnPush() Trigger). Something like this should work: PurchaseHeader := Rec; PurchaseHeader.SETRECFILTER; DATAPORT.RUNMODAL(DATAPORT::MyDataport, FALSE, PurchaseHeader);