Setfilter for rec in form by command button

Hi All,

I have a doubt in form. How to make apply filter for rec by click on command button,

Can anyone please tell me, if its possible?

Thanks in Advance,

SS

Yes, you have simply to set the filters on Rec variable inside the OnPush trigger.

Hi Daniele,

Thanks for ur reply. As you said i did. In my case if i (boolean field - Audited )click a gl entry in form, the other similar doc entry should also get ticked & if i press update only it should get vanished from view. but it works for first time thn i do sec time on entry, similar doc ticked & get vanished without click on update button. since press update click stores the setfilter.

code on boolean field

IF Audited THEN BEGIN

COMMIT;

GLEntry.RESET;

GLEntry.SETFILTER(“Entry No.”,’<>%1’,“Entry No.”);

GLEntry.SETRANGE(“Document No.”,“Document No.”);

GLEntry.SETRANGE(“Posting Date”,“Posting Date”);

IF GLEntry.FINDSET THEN

REPEAT

GLEntry.Audited := TRUE;

GLEntry.MODIFY;

//IF GLEntry.FIND(’+’) THEN

IsAudt := TRUE;

UNTIL GLEntry.NEXT = 0;

END;

MESSAGE(’%1’,IsAudt);

PurchlGL.UpdateAudited(IsAudt);


On Update Command Button Code:

IF IsAudit THEN

SETFILTER(Audited,’%1’,FALSE);

So, you need to modify some G/L Entry and not just set a filter.

In this case I suggest to replicate the standard approach used for Cust. Ledg. Entry: create a codeunit which performs the records modification (remember to set modify permission on table 17) and will be called inside the OnModifyRecord trigger of General Ledger Entries form.

Set the form object as editable and set as not editable all the fields except Audited: in this way it should work.

Hi Sir,

I can able to modify . My issue is related to setfilter.

On Opening form - Show Audited false

On making Audited True - Other related rec should also get Audited - true (It should stay until i give update click so v cannot setfilter Audited false for rec beco Other related doc winds up immediately it wnt stay. )

When giving update fn - Its should again show the Audited False (Like when On Open)

Trying for a better solution :frowning:

I wrote this code in table field Audited - OnValidate:

IF Audited THEN BEGIN

GLEntry.RESET;

GLEntry.SETFILTER(“Entry No.”,’<>%1’,“Entry No.”);

GLEntry.SETRANGE(“Document No.”,“Document No.”);

GLEntry.SETRANGE(“Posting Date”,“Posting Date”);

GLEntry.MODIFYALL(Audited,TRUE);

END;

This in Audited form field trigger OnAfterValidate:

CurrForm.UPDATE;

And this in OnPush trigger of a CommandButton added on form:

SETRANGE(Audited,FALSE);

And it’s working; can you try in this way?