Query on FIND,FINDSET,FINDFIRST,FINDLAST.

Hi All,

I theoritically understand the meaning of FIND,FINDSET,FINDFIRST,FINDLAST function but i am not able to implement practically…please explain me all these function with examples.mainly FIND and FINDSET function.

Thanks In Advance.

I suggest have a look at existing codes in reports,forms.codeunit and check how it has been used.

Hi Priya,

FIND is the old function, but still supported as it is still used in many functions and add-ons. It can basically do the same as FINDSET, FINDFIRST and FINDLAST by using the different parameters. FIND(’+’) = FINDLAST, FIND(’-) = FINDFIRST. But it can do more FIND(’=’) will find an exact match on the key values. FIND(’<’) will find records which are less than the key values and FIND(’>’) records which are larger than the key values. Plus you can use it together with ASCENDING(FALSE), which doesn’t work with the other.

FINDSET is used whenever you want to find records with the purpose of looping through the records. Like in a IF FINDSET THEN REPEAT xxx UNTIL NEXT = 0. You can specify the parameters as FINDSET(true, false), which means you’re finding records and intend to modify the records in the loop, but not the primary key. FINDSET(true,true) you do the same, but intend to also do a RENAME to update the primary key. using it without parameters is the same as FINDSET(false,false). The different parameters have an influence on the performance and isolation level of the loop, to prevent locking data you don’t need to lock.

Where FIND and FINDSET will always fetch a set of records, then both FINDFIRST and FINDLAST will only find one record. But don’t use this if you just want to know if any records exists within the filter you have been setting. In that case you should rather use ISEMPTY.

Thanks Erik,

after your rply i am makin a report in which i am retriving all the record of a single customer with help of detailled customer ledger entry within a date filter like,in filter i am using No.,Date Filter

suppose

No-10000,

Date filter -040110…040111

and in customer-onnafter

i use FIND(-)

this output me correctly by adding all the amounts from top to bottom within that date filter

but when i use FIND(+)

this outputs the last amount of that customer,and it does’t calculate from bottom to top with in date fiter.

Please explain me why FIND(+) is not giving the correct answer,why it acts like FINDLAST.

Thanks In Advance

Hi Erik,

As you told me that

1.FIND(+)=FINDLAST;

2.FIND(-)=FINDFIRST;

as the report i made the first statement (1) is correct and gives the same answer i.e last record with in that date filter.

and Statement (2) gives the calculated value from top to bottom of all records which are in that date filter.

The result i am getting in statement 2 is correct for FIND(-) bcoz this solves whole data from top to bottom and gives.but FINDFIRST provides only the first record that meets the condition,then why it gives the calculated data…

Please help me to understand this.

Thanks

Hi Priya,

I have no idea what you’re talking about!

Could you please explain what the calculation of values has to do with FINDFIRST, FINDLAST etc.?

Hi Erik,

Let me clear what i am talking about,as we knw every vendor has all its details in vendor ledger entry,so i want for a specific vendor i filter all its ledger detail with in date filter,and for that when i am using FIND(’+’) and FINDLAST it result into the last ledger record of that partcular vendor with in that date filter,and FIND(’-’) and FINDFIRST gives the total of the record from the begin of date filter to the last record with in date filter.

No.-10000

Date Filter = 040110…040111

and there is one variable TEMP which count total amount of that vendor with in this date filter.

Output-

1.when i am using FIND(+) and FINDLAST this gives

output := 20000 (last record amount)

  1. when i am using FIND(-) and FINDFIRST this gives

output := 52678913(Sum of all amount within this date filter);

i am confused bcoz i read that FINDFIRST finds the first record with in that date filter bt it calculates the sum of all ledger record.

Thanks

Ok now I think that I get you. I just don’t understand why you need any FIND function for this?

In NAV if you want a sum of vendor ledger entries filtered by vendor number and date, then you should be using FLOWFIELDS, or simply CALCSUM. And a field doing exactly that exists already on the vendor and it’s called “Net change”.