Page 1 of 1

Nested find() and search()

PostPosted: Tue Jun 26, 2012 7:53 pm
by hardina09
I need to work with foundset.find() wherein I need to do lookups in database and get he result. Based on the result I need to again relook up the database table and perform some actions.
for example: In my formA I am having Start button. When clicked need to check empID is in table by using
Code: Select all
foundset.find()
<somecode>
if(foundset.search())
<do some action>

if foundset.search() returns true, I need to lookup for the empID which department id belongs to. and then lookup for the category for that department. So on

In short for every stage I need to look for some information in table, based on information available need to perform actions and need to relook up table for the information.

Requires suggestions as early as possible.

Re: Nested find() and search()

PostPosted: Wed Jun 27, 2012 10:31 am
by omar
Are you saying that when you do your first lookup and a result is found you want to narrow down the resultset to less records?

Re: Nested find() and search()

PostPosted: Wed Jun 27, 2012 2:18 pm
by hardina09
Yes you can say that based on lookup need to narrow the the resultset.

Re: Nested find() and search()

PostPosted: Wed Jun 27, 2012 2:54 pm
by omar
Ok, in that case your in luck.

The search() has two optional parameters: clearLastResult and reduceSearch. So what you want to do is:

Code: Select all
foundset.find();
<somecode>
if (foundset.search()) {
   <do some action>
   foundset.find();
   <some more code>
   search(false, true)
}

Re: Nested find() and search()

PostPosted: Wed Jun 27, 2012 5:09 pm
by hardina09
Got you Omar. I have created test form trying to work with above code. Below is code which is not executing in exact flow

foundset.find()
foundset.empid=<somevalue>
if(foundset.search(true,false)) //found the empid, will execute the if part
{
foundset.find() //finds the deptnm wherein emp is working
foundset.dept_nm=<somevalue>
if(foundset.search(true,false) // found the deptnm for that empid will execute if part
//do someaction;
else // if no deptnm is found for found empid, will perform some other actions.
//do some action;
}
else //if empid is not found
//do some action

Somehow, even if deptnm does not match with the foundset.detpt_nm. It does not execute else part . In other word flow of if - else is not working properly.
Do you have any idea how flow works in nested find() and search().

Re: Nested find() and search()

PostPosted: Wed Jun 27, 2012 6:18 pm
by omar
I am not quite sure what it is that you trying to achieve. Are you talking about one form with one foundset (which is naturally based on 1 table) or multiple forms with different tables in their foundset?

Re: Nested find() and search()

PostPosted: Wed Jun 27, 2012 7:37 pm
by hardina09
It is based on one form with one foundset. Anyways, I got what I want in my application Previously if-else flow was not working properly. Reason-need to add correct parameter to search() at the correct time, that its.

Anyways, great help. Omar
Thanks.