I'm working on a suitelet that takes a saved searc...
# suitescript
r
I'm working on a suitelet that takes a saved search as input. I would like to determine record type based on search type. Here is what I'm having to do. Thoughts on mapping search types to record types?
n
If all you are using it for is to load and run the search, you don't have to specify type in the search.load(). But if you need it to do other stuff with the records returned in the search, you should just be able to get the search type with
search.searchType
so something like this
Copy code
const savedSearchId = scriptContext.request.parameters["custpage_saved_search"];

let savedSearch = search.load({id: savedSearchId})

const searchType = savedSearch.searchType

let rec = record.load({type: searchType, id: someRecordID})
r
search type is not the same as record type. you're supposed to use record type for record.load and search type for search.load. They're different enums
the savedSearch.searchType is a good thought. easier than what i'm doing
n
That may be true in some edge cases, but i think they are natively the same For example a search on projects would return a search.searchType of 'job' And loading a project record you can use
record.load({type: 'job', id: 123})
ah wait youre right.
transactions would return 'transaction' for the search type, but record you have to specify which transaction
Oh ok. What if when you load the saved search you just add in the column 'recordType' before you rn the search. You can inject columns and filters into a loaded search. Then you can retrieve the recordType from each line of the saved search
r
i think what i'm doing in getType is safer. i'm not sure that recordType would be a column for every type of saved search. i think the record type of a saved saved search search is actually a search type tho, not a record type
although when i search for it gives me capitalized which doesn't match either enum. frustrating