Make list from Workdrive Folder
Hi,
Today, my challenge is to simplify and optimize my drop-down list where I retrieve the list of files present in a WorkDrive folder.
I had to create a custom function to replace and display special characters.
Then, I need the file ID to open it in one part of my application, but I would like the file name to be displayed.
I was unable to make the file name visible, and then its ID used. I had to create the file name + its ID, then in the other part of my application, I split the name to retrieve only its ID.
I don't know if I'm explicit enough, I'll try to provide you with images and code to better understand.
File name in Workdrive :

File name in my List Field :
My custom function to decode HTML :
- string decodeHtml(string text)
- {
- text = text.replaceAll("é","é");
- text = text.replaceAll("è","è");
- text = text.replaceAll("ê","ê");
- text = text.replaceAll("à","à");
- text = text.replaceAll("â","â");
- text = text.replaceAll("î","î");
- text = text.replaceAll("ô","ô");
- text = text.replaceAll("û","û");
- text = text.replaceAll("ç","ç");
- text = text.replaceAll(" "," ");
- // Espace
- return text;
- }
My Deluge Script to list all files in WorkDrive with my custom function :
- header = Map();
- header.put("Accept","application/vnd.api+json");
- response = invokeurl
- [
- url :"https://www.zohoapis.com/workdrive/api/v1/files/FOLDER_ID/files"
- type :GET
- headers:header
- connection:"creatorcon"
- ];
- files = response.get("data");
- nameList = List();
- for each file in files
- {
- fileId = file.get("id");
- fileName = thisapp.decodeHtml(file.get("attributes").get("display_attr_name")) + " - " + file.get("id");
- nameList.add(fileName);
- }
- input.choose_xls_file:ui.add(nameList);
My Deluge script in my application where I split the name of item in list :
- inputString = input.choose_xls_file;
- separatorIndex = inputString.indexOf(" - ");
- if(separatorIndex != -1)
- {
- getItemId = inputString.substring(separatorIndex + 3);
- getFileName = inputString.substring(0,separatorIndex);
- }
- queryData = Map();
- response = zoho.sheet.getSheets(getItemId,"creatorcon");
- worksheetNames = response.get("worksheet_names");
- worksheetName = "";
- for each worksheet in worksheetNames
- {
- worksheetName = worksheet.get("worksheet_name");
- worksheetId = worksheet.get("worksheet_id");
- }
- responseV2 = zoho.sheet.getRecords(getItemId,worksheetName,queryData,"creatorcon");
Please, can you help me to optimize this ?
I'm sure there is a way to make a list with the file names, but use their IDs without having to display them.
Thanks all :)