Search Using a Specific Record Field
The following sample shows how to search for records using the value of the operationdisplaytext field. If you run this sample in your account, be sure to replace the placeholder value <transactionId> with a valid value from your account.
Note:
This sample script uses the require function so that you can copy it into the SuiteScript Debugger and test it. You must use the define function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.
/**
* @NApiVersion 2.x
*/
require(['N/search'], function(search) {
var mySearch = search.create({
type: search.Type.TRANSACTION,
columns: ['item', 'operationdisplaytext'],
filters: [
['internalid', search.Operator.ANYOF, <transactionId>],
'and',
['operationdisplaytext', search.Operator.EQUALTO, 20]]
});
var myResultSet = mySearch.run();
var resultRange = myResultSet.getRange({
start: 0,
end: 20
});
});
Related Topics
- N/search Module Script Samples
- Search for Customer Records and Log First 50 Results
- Search for Sales Order Records
- Load a Search for Sales Order Records and Use a Callback Function to Process Results
- Load a Search for Sales Order Records and Return the First 100 Search Results
- Load and Run a Paginated Search and Process the Results
- Create a Search for a Custom Record Type
- Search for Items in a Custom List
- Delete a Saved Search
- SuiteScript 2.x Modules
- SuiteScript 2.x