how do I query the state table? I have the full/n...
# suitescript
p
how do I query the state table? I have the full/name of the state. Is this the correct way to search the table? var srch = search.create({ type: search.Type.STATE, columns: [{ name: 'id' }], filters: [{ name: 'fullName', operator: search.Operator.IS, values: [stState] }] }); var resultSet = srch.run();
s
var stateSearchObj = search.create({ type: "state", filters: [ ["country","anyof","CA"] ], columns: [ search.createColumn({ name: "id", sort: search.Sort.ASC, label: "Id" }), search.createColumn({name: "fullname", label: "Full Name"}), search.createColumn({name: "shortname", label: "Short Name"}), search.createColumn({name: "country", label: "Country"}), search.createColumn({name: "inactive", label: "Inactive"}) ] }); var searchResultCount = stateSearchObj.runPaged().count; log.debug("stateSearchObj result count",searchResultCount); stateSearchObj.run().each(function(result){ // .run().each has a limit of 4,000 results return true; });
This should work
p
thanks
s
you should use
search.Type.STATE
over the 'state' string.
s
It really doesn't make any difference. Have you had issues with just using the string?