Filter on form

Hi

PurchOrderHeader.SETRANGE(“Document Type”,“Document Type”::Quote);
PurchOrderHeader.SETFILTER(“Purchaser Code”,USERID);
IF PurchOrderHeader.FIND(’-’) THEN
BEGIN
FrmQ.GETRECORD(PurchOrderHeader);

what i need to complete this code to open Quote form with this filter

PurchOrderHeader.SETRANGE(“Document Type”,“Document Type”::Quote);
PurchOrderHeader.SETFILTER(“Purchaser Code”,USERID);
IF PurchOrderHeader.FIND(’-’) THEN
form.run(49 , PurchOrderHeader)

Thank you for quik reply

but i put this code in Form - OnOpenForm()

In “OnOpenForm” of which form?

If you are talking about the Purchase Quote form, then you just need the following code:

FILTERGROUP(2);
SETRANGE("PurchaserCode",USERID);
FILTERGROUP(0);

setting the FILTERGROUP to “2” before prevents the user from removing the filter manually.

If you have access to the “Responsibility Center” functionality in NAV you could utilize this directly by assigning a responsibility center to each user.
You would not need any changes to the program code as such a functionality is exactly provided by this.

Thanks Thomas Brodkorb

It’s work

Hi Thomas Brodkorb

I’m try to add a new record on this filter but i can’t

By simply hitting F3 you actually create a new record - BUT, as fields in the new record which are included in filtering are still blank, the record falls out of scope of the filter, as result, you don’t see it.
If you remove the filter, then you’ll see a bunch of new empty records, where only Doc No is filled in.