Is it possible to retrieve the saved search title ...
# suitescript
x
Is it possible to retrieve the saved search title using search id? currently, I have added a script parameter to select saved search and it requires to use the search title for email subject
m
const yourSearch = search.load({id: “xxxxx”}) yourSearch.title
x
@Miki already tried that way, but return null i think the above search.title function is only used while creating saved search
j
@Xiaoxin Li, wow. You're right. Looking at the JSON of a loaded search the title key shows a null value... Seems like the only way around this is to use a saved search to get you saved search title like this var searchTitle = ''; var savedsearchSearchObj = search.create({ type: "savedsearch", filters: [["internalidnumber", "equalto", "{{Your Search ID}}"]], columns: [search.createColumn({ name: "title", label: "Title" })] }); savedsearchSearchObj.run().each(function (result) { searchTitle = result.getValue('title') return true; });
m
well, then lookupFields might be better option. I have tested and it works just fine.
Copy code
const title = search.lookupFields({
    type: search.Type.SAVED_SEARCH,
    id: 2245,
    columns: ["title"],
}).title;
x
it works, thanks @Miki