Saved search code for fetching all the files from a folder

Saved search

  getAllCSVFiles: function (errorFolderId) {

                var tempCSVArr = [];
                var fileSearchObj = search.create({
                    type: "file",
                    filters: [
                        ["folder", "anyof", errorFolderId]
                    ],
                    columns: [
                        search.createColumn({ name: "internalid", label: "Internal ID" }),
                    ]
                });
                fileSearchObj.run().each(function (result) {
                    tempCSVArr.push(result.getValue(fileSearchObj.columns[0]));
                    return true;
                });
                return tempCSVArr;
            },

Leave a comment

Your email address will not be published. Required fields are marked *