jimmyrose1

Content Snare - Code by Zapier - Extract URLs for all files

Mar 3rd, 2024
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. const data = JSON.parse(inputData.data);
  2. output = {};
  3. // Fill in fields
  4. output['Request ID'] = data.id;
  5. output['Request Name'] = data.name;
  6. output['URL'] = data.url;
  7. output['Due Date'] = data.due_date;
  8. output['Folder'] = data.folder_name;
  9. output['Share Link'] = data.share_link;
  10. output['Template Name'] = data.request_template_name;
  11. output['Owner'] = data.owner_name;
  12. output['Client Name'] = data.client.full_name;
  13. output['Company Name'] = data.client.company_name;
  14. output['Email'] = data.client.email;
  15. output['Phone'] = data.client.phone;
  16. var files = [];
  17. data.pages.forEach(page => {
  18. page.sections.forEach(section => {
  19. section.fields.forEach(({ name, values }) => {
  20. values.forEach((value) => {
  21. if (typeof value === 'string' && value.startsWith('https://api.contentsnare.com/rails/active_storage/blobs/')) {
  22. files.push(value);
  23. }
  24. })
  25. })
  26. })
  27. })
  28. output['Files'] = files.join(',');
Add Comment
Please, Sign In to add comment