NEW TO SERVOY, SEARCH BOX TO LOOK FOR RECORD

Hi, totally new to servoy and java. I am trying my best to understand and learn things but its a big learning curve.

Basically I have a form, linked to a table that has ‘MFNO’ as the unique key.

I want a search box on a form with a button so that when I enter a specific MFNO in the text box and click the search button, it finds the record in the table and displays a few fields from that table on the form.

I have no idea how to do this. Can anyone help, I know its simple.

Hi Danny,

In short:

  1. Create a form variable
  2. Bind it to the textbox
  3. Set the form in find mode
  4. Point the searchvalue to the corresponding field
  5. Do the search

This is code for a simple search:

if(foundset.find()){   // Enter find mode
    city = 'Berlin';   // Assign a search criteria
    foundset.search(); // Execute the query and load the records
}

Your code will have to look something like this:

var searchCity = "";  // bind this form variable to the search field
if(foundset.find()){   // Enter find mode
    city = searchCity;   // Assign a search criteria
    foundset.search(); // Execute the query and load the records
}

Ususally the form variable declaration will be at the top of the forms *.js file and the search code could be in the function that handles the click event for the search button.

Also take a look at the wiki: http://wiki.servoy.com/display/public/DOCS/Working+with+Data#WorkingwithData-FindMode

That should get you started, have fun!

Thanks for the reply, I have tried to put the code in but I am getting this in the search text box when I click the search button

org.mozilla.javascript.UniqueTag@627f4e85: NOT_FOUND

My button code:

function onAction(event) {

if(foundset.find()){ // Enter find mode
MFNO = SearchMFNO1; // Assign a search criteria
foundset.search(); // Execute the query and load the records
}

I have declared the form variable
var SearchMFNO1=" ";

Sorry, totally new to this.

Thanks

Ignore that previous post, I got it working, was my mistake.

Thanks for your help :)