# svyLookup v1

### Reference Guides

* [**API Documentation v1.0.0**](/guides/develop/programming-guide/extensions/modules/svylookup/svylookup-v1.0.0/api-documentation-v1.0.0.md)
* [**Base Form svyLookupTable v1.0.0**](/reference/servoyextensions/modules/home-2/svylookup-v1.0.0/base-form-svylookuptable.md)
* [**Base Form AbstractLookup v1.0.0**](/guides/develop/programming-guide/extensions/modules/svylookup/svylookup-v1.0.0/base-form---abstractlookup-v1.0.0.md)

### Overview

The svyLookup module provides a UX pattern for quickly finding and returning a record. It is similar to a type-ahead field, but allows for an extended UI, searching and data-binding.

This module provides an out-of-the-box grid implementation, but is also extensible to allow for other UI types

This [**quick screencast**](https://www.screencast.com/t/fxtRsOho) shows the example

### Example

![Example Look-Up](/files/MHnzKEzH0ffJZSMoQrFl)

### Example Usage

It takes just a few lines of code to configure and show a robust lookup component. The selected record can be handled in a callback.

#### Show Lookup

```javascript
       // create lookup object
	var lookupObj = scopes.svyLookup.createLookup(datasources.db.example_data.products.getDataSource());
	
	// add fields
	
	// related data is supported
	lookupObj.addField('products_to_categories.categoryname').setTitleText('Category');
	lookupObj.addField('productname').setTitleText('Product');
	lookupObj.addField('products_to_suppliers.companyname').setTitleText('Supplier');
	
	// Valuelists and non-searchable fields supported
	lookupObj.addField('discontinued')
		.setTitleText('Available')
		.setSearchable(false)
		.setvalueListName('product_availability');
	
	// formatted, non-searchable field example
	lookupObj.addField('unitprice')
		.setSearchable(false)
		.setTitleText('Price')
		.setFormat('#,###.00')
	
	// show pop-up
	var component = elements.productID;
	var initialValue = application.getValueListDisplayValue(elements.productID.getValueListName(),selectedProductID);
	lookupObj.showPopUp(onSelect,component,null,null,initialValue);
```

#### Handle selection in callback

```javascript
	function onSelect(record){
		if(record){
			selectedProductID = record.productid
		}
	}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/guides/develop/programming-guide/extensions/modules/svylookup/svylookup-v1.0.0.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
