(Deluge) Filtering fetched records

(Deluge) Filtering fetched records

I am trying to create a script that checks the status of the zoho sign document where the field waiver_status equals sent, unopened or viewed. 

We have thousands of records so I was trying to filter the fetched records but it is telling me I cannot and giving me a generic error. 

The error is on line two. I am guessing 
  1. // Fetch all records in the form Waiver where Waiver_Status equals sent, unopened, or viewed
  2. recordsToProcess = Waivers.filter("(Waiver_Status == 'sent' or Waiver_Status == 'unopened' or Waiver_Status == 'viewed')");

  3. // Loop through each record
  4. for each record in recordsToProcess
  5. {
  6.     // Run the provided code for each record

  7.     // Fetch document by Sign_ID
  8.     res = zoho.sign.getDocumentById(record.Sign_ID.tolong());

  9.     // Check if document retrieval is successful
  10.     if(res.get('status') == "success")
  11.     {
  12.         // Get request status
  13.         request_status = res.get('requests').get('request_status');

  14.         // Process based on request status
  15.         if(request_status == 'completed')
  16.         {
  17.             info "Document signed by all parties";
  18.             record.Waiver_Status = "SIGNED";
  19.         }
  20.         else if(request_status == 'inprogress')
  21.         {
  22.             info 'Document in progress';

  23.             // Get actions
  24.             actions = res.get('requests').get('actions');

  25.             // Loop through each action
  26.             for each i in actions
  27.             {
  28.                 // Check action status
  29.                 if(i.get('action_status') == "UNOPENED" || i.get('action_status') == "VIEWED")
  30.                 {
  31.                     record.Waiver_Status = i.get('action_status');
  32.                 }
  33.             }
  34.         }
  35.         else if(request_status == 'recalled')
  36.         {
  37.             record.Waiver_Status = "RECALLED";
  38.         }
  39.         else if(request_status == 'expired')
  40.         {
  41.             record.Waiver_Status = "EXPIRED";
  42.         }

  43.         // Update the record in Zoho Creator
  44.         Waivers.update(record);
  45.     }
  46. }

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now