SETSELECTIONFILTER

Hello,

I am aware that in NAV, SETSELECTIONFILTER will MARK records that have been selected from a list form, but the issue I am having a problem with is that it doesn’t MARK records if they are all selected at once (by clicking the upper left-hand corner of the table box)

Does anyone know a way that I could programatically detect if a user selected all records in this manner and MARK them?

Thanks for any help.

Chris Boyle

If all records in your form are selected, NAV does not MARK them. Try and place this sample code on a CommandButton and some form, to see the different filters NAV returns to you:

CurrForm.SETSELECTIONFILTER(Rec2);
MESSAGE(’%1%2’,Rec2.COUNT,Rec2.GETFILTERS);

Thank you Soren,

As I mentioned, I know about the fact that Nav doesn’t mark recs if all are selected. I am looking for a way to detect when the user has in fact selected all.

Do you know of a way?

Chris

Hi Chris,

how about comparing the number of records?

Try this:

Currform.SETSELECTIONFILTER(REC);

REC2 := REC;

MESSAGE(’%1’,REC2.COUNT=REC.COUNT);

//============

If the result turns YES it means the user has selected all records in the form…

Regards,

-TR-

Any other scenarios than “selecting all” returns marked records. That should make it pretty easy to figure out what the user did.

Thank you,

But unfortunately, there are in fact TWO scenarios for which no records will be marked.

  1. Selecting All

  2. Not Selecting Any

Therefore, it is not “pretty easy” to figure out what the user did. I can’t assume that if no records are MARKED, that the user selected all—maybe they just didn’t select anything.

Here are the scenarios:

  1. Selecting all, no filter is set on your record

  2. Selecting current record (the one your cursor is on, without highlighting it) returns a filter on the primary key

  3. Selecting multiple returns a filter with marked records.

Oh…

I see. I didn’t realize that “selecting all” returned no filter, as well as, no marked recs. I thought that the filter would still return the primary key of the record that the cursor was on even if “selecting all”

Thanks, I’ll try it.