Vedachalam Mahadevan
03/11/2025, 2:27 PMCeligo AI
03/11/2025, 2:28 PMAI generated answer (using internal Slack threads):To read the first file from the search result, you can use the
run().getRange()
method on the search object. This method returns an array of search results. You can specify the range of results you want to retrieve by providing the start and end index. To get the first file, you can use the start index as 0 and end index as 1. Here is how you can do it:
javascript
var fileSearchObj = search.create({
type: "file",
filters:
[
["folder","anyof",1], // Folder ID
"AND",
["name","is","a.pdf"] // File name
],
columns:
[
search.createColumn({
name: "name",
sort: search.Sort.ASC
}),
"folder",
"documentsize",
"url",
"created",
"modified",
"filetype"
]
});
var searchResult = fileSearchObj.run().getRange({
start: 0,
end: 1
});
if(searchResult.length > 0) {
var firstFile = searchResult[0];
// Now you can read the details of the first file
var fileName = firstFile.getValue({name: "name"});
var folder = firstFile.getValue({name: "folder"});
var documentSize = firstFile.getValue({name: "documentsize"});
var url = firstFile.getValue({name: "url"});
var created = firstFile.getValue({name: "created"});
var modified = firstFile.getValue({name: "modified"});
var fileType = firstFile.getValue({name: "filetype"});
}
In this code, searchResult[0]
gives you the first file from the search result. You can then use the getValue()
method to read the details of the file.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
03/11/2025, 2:28 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.849033
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.843338907
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841892958
Celigo AI
03/11/2025, 2:28 PM