


responseMap = Map(); attributeInfo = Map(); dataInfo = Map(); headerMap = Map(); headerMap.put("Accept","application/vnd.api+json"); // First Name and Record ID from the argument AttributeInfo.put("name",Name + recordId); // Parent folder ID under which you want to maintain the lead folders attributeInfo.put("parent_id","e8gn06f2d7b3a48044090b7217524be95c9ac"); dataInfo.put("attributes",attributeInfo); dataInfo.put("type","files"); responseMap.put("data",dataInfo); folderCreateResponse = invokeurl [ url :"https://zohoapis.in/workdrive/api/v1/files" type :POST parameters:responseMap.toString() headers:headerMap connection:"workdrive_oauth_connection" // Connection Link Name created in the prerequisites ]; info folderCreateResponse; |
requestBody = Map(); dataList = List(); record = Map(); // Set field values record.put("WorkDrive_Folder_ID",driveId); // Add record to list dataList.add(record); // Wrap data requestBody.put("data",dataList); updateLead = invokeurl [ url :"https://zohoapis.in/crm/v8/Leads/" + recordId type :PUT parameters:requestBody.toString() connection:"crm_oauth_connection" ]; info updateLead; |

// data.Entity and data.EntitiyId are the module and record ID from PageLoad const response = await zrc.get( "/crm/v8/" + data.Entity + "/" + data.EntityId ); var workdriveFolderId = response.data.data[0].WorkDrive_Folder_ID; |
workDriveZrc = zrc.createInstance({ baseUrl: "https://www.zohoapis.in/workdrive/api/v1", connection: "workdrive_oauth_connection", }); |
let apiResponse = await workDriveZrc.get( "/files/" + workdriveFolderId + "/files", { headers: { Accept: "application/vnd.api+json", }, } ); |
try { const previewResponse = await workDriveZrc.get( "/files/" + resourceId + "/previewinfo", { headers: { Accept: "application/vnd.api+json", }, } ); parsed = JSON.parse(previewResponse.data); console.log("Preview Data:", parsed); // Extract the preview_url from the expected location previewUrl = parsed && parsed.data && parsed.data.attributes && parsed.data.attributes.preview_url || null; // Remove surrounding quotes if server wrapped the url in quotes if (typeof previewUrl === "string") { previewUrl = previewUrl.replace(/^"(.*)"$/, "$1").trim(); } } catch (err) { console.error("Error fetching preview info for resource:", resourceId, err); } function showPreview(previewUrl, fileName, permalink) { var modal = document.getElementById("modal-container"); var thumbnailFrame = document.getElementById("thumbnail-img"); var caption = document.getElementById("caption"); var workdriveLink = document.querySelector(".redirect-workdrive"); // Load the preview URL into the iframe thumbnailFrame.src = previewUrl; // Set the file name in caption and workdrive link caption.textContent = fileName; workdriveLink.setAttribute("data-link", permalink); // Show the modal modal.style.display = "block"; } |
async function workdriveUpload(file, fileType, fileName, folderId) { const fileBlob = new Blob([file], { type: fileType }); try { const formData = new FormData(); formData.append("filename", fileName); formData.append("parent_id", String(folderId).trim()); formData.append("content", fileBlob); const uploadResponse = await workDriveZrc.post( "/upload", formData, { headers: { "Content-Type": "multipart/form-data", }, } ); console.log("Upload response:", uploadResponse.data); return uploadResponse; } catch (error) { console.error("Error uploading file:", error); throw error; } } |





