Best way to populate JSON query in Deluge - exemple of JSON STRING MAP to create contract with api

Best way to populate JSON query in Deluge - exemple of JSON STRING MAP to create contract with api


Hi every one just want to share about process with you.. I just want to share my code to build JSON string in DELUGE.

As the api is not as complete as javascript.. we need to have tricks..  For myself i have 1rst try to use the combination of Map(); and List(); with toString(); function to build the perfect JSON Map but it was realy a long script, difficult to read.. so now i just concatenate string or part of string...

Its important to create json string instead of pure json as square Bracket List "[0,1,2,..]" is not supported and will be squish into curly brace "{}" on save.

Exemple :  THIS 
  1. {
  2.   "metaApiName": "contract-end-date",
  3.   "inputs": [
  4.     {
  5.       "inputApiName": "contract-end-date",
  6.       "inputValue": 3
  7.     },
  8.     {
  9.       "inputApiName": "n-monthsyears-value",
  10.       "inputValue": "contract_month"
  11.     },
  12.     {
  13.       "inputApiName": "n-monthsyears-term",
  14.       "inputValue": 0
  15.     }
  16.   ]
  17. }

  

  1. will become this on save wich is incorrect
  2. {
  3.   "metaApiName": "contract-end-date",
  4.   "inputs": {
  5.     {
  6.       "inputApiName": "contract-end-date",
  7.       "inputValue": 3
  8.     },
  9.     {
  10.       "inputApiName": "n-monthsyears-value",
  11.       "inputValue": "contract_month"
  12.     },
  13.     {
  14.       "inputApiName": "n-monthsyears-term",
  15.       "inputValue": 0
  16.     }
  17.   }
  18. }

So thirst thing i suggest is build the entire request in json an then passing it as string with escaped caracters as bellow 

  1. jsonString = "{\"metaApiName\":\"contract-end-date\",\"inputs\":[{\"inputApiName\":\"contract-end-date\",\"inputValue\":3},{\"inputApiName\":\"n-monthsyears-value\",\"inputValue\":24},{\"inputApiName\":\"n-monthsyears-term\",\"inputValue\":0}]}"

Then you can split the request string in parts and build the full request string with 
  1. string = "3"
  2. string += "2"
  3. string += "3"
  4. info string; = "123";

, add variable with + operator and the outpout will be correct.


  1. InnerArrayVaraibleSTRING = "{\"inputApiName\":\"contract-end-date\",\"inputValue\":3},";

  2. InnerArrayVaraibleSTRING += "{\"inputApiName\":\"n-monthsyears-value\",\"inputValue\":24},";

  3. InnerArrayVaraibleSTRING += "{\"inputApiName\":\"n-monthsyears-term\",\"inputValue\":0}";


  4. jsonString = "{\"metaApiName\":\"contract-end-date\",\"inputs\":[ " +   InnerArrayVaraibleSTRING  +  "]}";

And bellow the full exemple to build the map of a contract :


  1. TypeDeContrat = "you-contract-type-id"; // Contract type id = url part of edit contract type
  2. contrat_title  = "Contrat Test 2024 Auto"; // Contract title
  3. requester = "NAME OF REQUESTER";
  4. contrat_description = "Description of the contract";
  5. CounterpartNAme = "ACCOUNT-ID-IN-ZOHO-CONTRACT";
    // Counterpart id = url part id of counterpart
    // (exemple : green veggy society is certainely  : green-veggy-society )
  6. counterpartUserNAmeMAil = "COUNTERPART EXISTING CONTACT EMAIL";
  7. contract_month = 36; // the duration of my contrat // this one start with sign for contract_month ;


  8. //Contract map title and template
  9. contrat_content = "{\"metaApiName\":\"contract-type\",\"inputs\":[{\"inputApiName\":\"contract-type\",\"inputValue\":\""+ TypeDeContrat +"\"}]},{\"metaApiName\":\"title\",\"inputs\":[{\"inputApiName\":\"title\",\"inputValue\":\""+  contrat_title +  "\"}]},{\"metaApiName\":\"description\",\"inputs\":[{\"inputApiName\":\"description\",\"inputValue\":\""+ contrat_description + "\"}]},"; 

  10. //Contract map asker
  11. contrat_content += "{\"metaApiName\":\"requester-name\",\"inputs\":[{\"inputApiName\":\"requester-name\",\"inputValue\":\""+ requester + "\"}]},";

  12. //Contract map counterpart
  13. contrat_content += "{\"metaApiName\":\"party-b-name\",\"inputs\":[{\"inputApiName\":\"party-b-name\",\"inputValue\":\""+ CounterpartNAme + "\"}]},{\"metaApiName\":\"counterparty-primary-contact\",\"inputs\":[{\"inputApiName\":\"party-b-primary-contact-name\",\"inputValue\":\""+ counterpartUserNAmeMAil + "\"}]},";

  14. contrat_content += "{\"metaApiName\":\"contract-term\",\"inputs\":[{\"inputApiName\":\"contract-term\",\"inputValue\":true}]},{\"metaApiName\":\"is-renewable\",\"inputs\":[{\"inputApiName\":\"is-renewable\",\"inputValue\":false}]},{\"metaApiName\":\"contract-effective-date\",\"inputs\":[{\"inputApiName\":\"contract-effective-date\",\"inputValue\":1}]},";

  15. //Contract map Basic Options i selected (start with signature for x month ) 
  16. contrat_content += "{\"metaApiName\":\"contract-end-date\",\"inputs\":[{\"inputApiName\":\"contract-end-date\",\"inputValue\":3},{\"inputApiName\":\"n-monthsyears-value\",\"inputValue\":" + contract_month + "},{\"inputApiName\":\"n-monthsyears-term\",\"inputValue\":0}]}";

  17. // concatenate all input field list in brackets 
  18. inputfieldlist = "[" + contrat_content + "]";
  19. // Finaly add anythings to the final json array map
  20. input_contract_map = "{\"externalSource\": true, \"inputfields\":" + inputfieldlist + "}";

  21. //Show and debug the array maps generated
  22. info input_contract_map;


You can notice  the formula  : 

 \"inputValue\":\""+  contrat_title +  "\" , where contrat_title = "string_variable";
double quote is escaped before string and variable concatenation to ensure string variable to appear as string.. 
as 
"inputValue": " +  contrat_title  +  " ,  
become  "inputValue": "string_variable " ,




Then you just have to put it to add it to the request :


  1. headerMap = Map();
  2. headerMap.put("Content-Type","application/json");

  3. //GET ZOHO CONTRACT EXEMPLE 


  4. // CREATE THE CONTRACT 
  5. //url :"https://contracts.zoho.eu/api/v1/createcontract" // create with subfields
  6. response_create_contract = invokeurl
  7. [
  8. url :"https://contracts.zoho.eu/api/v1/contracts"
  9. type :POST
  10. parameters: input_contract_map
  11. headers:headerMap
  12. detailed:true
  13. connection: "YOUR_CONNEXION_NAME"
  14. ];
  15. info response_create_contract;


If you have better way to ensure good encoding of the JSON string please comment and share ! 
    • Sticky Posts

    • 11 Common API Errors and How to Prevent Them

      Zoho Contracts offers an extensive set of APIs using which you can integrate with your applications and build custom solutions. However, while using them and executing your code, you might face some errors. The reason might be due to any of the following
    • Organization Parameter in API Calls

      Zoho Contracts now supports the multi-org feature where users can be part of multiple organizations. You can now manage contracts across multiple organizations with separate Zoho Contracts accounts for each organization. Users who are part of multiple
    • Zoho Contracts API Documentation

      Greetings! The API documentation of Zoho Contracts is now available. Please access it from the below link. https://www.zoho.com/contracts/api/introduction.html You can post your queries and problems relating to Zoho Contracts API in this developer forum.
      • Recent Topics

      • Scheduling Calls in CommandCenter / Blueprints

        I would love it if you could add a function to schedule a call in the lead's record for a future date. I know you can add a Task by going to Instant Actions > Task and completing the form: These tasks go into the lead's record under Open Actions. But
      • open word file in zoho writer desktop version

        "How can I open a Microsoft Word (.doc or .docx) file in Zoho Writer if I only have the file saved on my computer and Zoho Writer doesn't appear as an option when I try 'Open with'? Is there a way to directly open the .doc file in Zoho Writer?"
      • Adding contact role to a specific deal js sdk malfunctioning

        i was trying to add the contact role to a specific deal contact but repeatedly i am getting this error: { "code": "SUCCESS", "details": { "statusMessage": { "code": "INVALID_DATA", "details": { "expected_data_type": "jsonobject" }, "message": "body",
      • How to invite friends on other social media platforms to one of my group chats in arattai?

        Hello, I have formed chat groups in arattai. I want to invite my friends on other social media platforms like WhatsApp/ FB to one of my groups. Different friends would be invited to different groups. How to share an invite link of one of my groups to
      • Zoho PDF editor has a lot of issues.

        Zoho PDF editor needs a lot of work. It hangs and glitches a lot. Deletes annotations and clearings randomly.
      • So we ran with it for the week

        In our company i bit the bullet and ran with FSM for a whole week. Service calls, deliveries and surveys. Covering about 30-120 miles a day to domestic properties. Loved the appointment list and satnav integration. Loved the timer to measure the appointments.
      • link to any Belgian bookkeeping software?

        Hello, Does anyone on this Forum can help me with the question whether the ZOHO CRM (Invoices) or ZOHO Book can be linked to software that is used for Belgian Bookkeeping/accountancy? By linking, I mean either with the help of a middleware program or either by the ability to export the custom made reports as CSV-files... If someone has an experience with online CRM-Accountancy in Belgium, with ZOHO (or other), it would be great to read it... Thank you
      • Client Script | Update - Introducing Subform Events and Actions

        Are you making the most of your subforms in Zoho CRM? Do you wish you could automate subform interactions and enhance user experience effortlessly? What if you had Client APIs and events specifically designed for subforms? We are thrilled to introduce
      • Kaizen #152 - Client Script Support for the new Canvas Record Forms

        Hello everyone! Have you ever wanted to trigger actions on click of a canvas button, icon, or text mandatory forms in Create/Edit and Clone Pages? Have you ever wanted to control how elements behave on the new Canvas Record Forms? This can be achieved
      • how to use validation rules in subform

        Is it possible to use validation rules for subforms? I tried the following code: entityMap = crmAPIRequest.toMap().get("record"); sum = 0; direct_billing = entityMap.get("direct_billing_details"); response = Map(); for each i in direct_billing { if(i.get("type")
      • Global Sets for Multi-Select pick lists

        When is this feature coming to Zoho CRM? It would be very useful now we have got used to having it for the normal pick lists.
      • stock

        bom/bse : stock details or price =STOCK(C14;"price") not showing issue is #N/A! kindly resolve this problem
      • Zoho sheet desktop version

        Hi Zoho team Where can I access desktop version of zoho sheets? It is important as web version is slow and requires one to be online all the time to do even basic work. If it is available, please guide me to the same.
      • ZOHO SHEETS

        Where can I access desktop version of zoho sheets? It is important to do basic work If it is available, please guide me to the same
      • Option to Empty Entire Mailbox or Folder in Zoho Mail

        Hello Zoho Mail Team, How are you? We would like to request an enhancement to Zoho Mail that would allow administrators and users to quickly clear out entire folders or mailboxes, including shared mailboxes. Current Limitation: At present, Zoho Mail only
      • Zoho Books - France

        L’équipe de Zoho France reçoit régulièrement des questions sur la conformité de ses applications de finances (Zoho Books/ Zoho Invoice) pour le marché français. Voici quelques points pour clarifier la question : Zoho Books est un logiciel de comptabilité
      • Using Zoho Flow to create sales orders from won deal in Zoho CRM

        Hi there, We are using Zoho Flow to create sales orders automatically when a deal is won in Zoho CRM. However, the sales order requires "Product Details" to be passed in "jsonobject", and is resulting in this error: Zoho CRM says "Invalid input for invalid
      • Is Zoho Sheet available for Linux ?

        Is Zoho Sheet available for Linux ?
      • how to disable staff selection Zoho Booking integrated to SalesIQ?

        currently there is only one Consultant in my Zoho Bookings like this I integrate Zoho Bookings into Zoho SalesIQ to create a chatbot. Unfortunately, even though I only have one consultant for a consultation, the user have to pick the consultant. It will
      • Zoho Bookings No Sync with Outlook

        Zoho Bookings appointments are showing on my Outlook Calendar but Outlook events are not showing on Zoho Bookings. How do I fix this?
      • End Date in Zoho Bookings

        When I give my appointments a 30 minutes time I would expect the software not to even show the End Time.  But it actually makes the user pick an End Time.  Did I just miss a setting?  
      • Custom confirmation message

        How can I change the message that users see after they submit the booking form? I have to confirm some details before their appointment is officially "confirmed", so I want to change it where it doesn't say their appointment is "confirmed" but rather
      • Issue showing too many consultations in my workspace link.

        Hi Team, I’ve set up two Workspaces to track meetings from different sources. So far, this has been working well, and the two Workspaces are differentiated without any issues. However, when I navigate to Consultations and share the link to my personal
      • All new Address Field in Zoho CRM: maintain structured and accurate address inputs

        The address field will be available exclusively for IN DC users. We'll keep you updated on the DC-specific rollout soon. It's currently available for all new sign-ups and for existing Zoho CRM orgs which are in the Professional edition. Managing addresses
      • Recurring Supervisor Rule Reminders for Open/In-Progress Tickets

        Hello Zoho Support Team, I would like to suggest a potential improvement regarding reminders for tickets and activities in Zoho Desk. Currently, it is possible to set reminders only once. In the Supervisor Rules section, it is possible to configure reminders
      • Improved RingCentral Integration

        We’d like to request an enhancement to the current RingCentral integration with Zoho. RingCentral now automatically generates call transcripts and AI-based call summaries (AI Notes) for each call, which are extremely helpful for support and sales teams.
      • Deluge sendmail in Zoho Desk schedule can't send email from a verified email address

        I am trying to add a scheduled action with ZDesk using a Deluge function that sends a weekly email to specific ticket client contacts I've already verified the email address for use in ZDesk, but sendmail won't allow it in its "from:" clause. I've attached
      • Zoho Learn & Zoho Connect

        Hi, Is there a way to sync the knowledge base we have in Zoho Learn with the manuals section is Zoho Connect? Thanks,
      • Addin Support in Zoho Sheet

        Is there any addin support available in zoho sheet as like google marketplace to enhance productivity by connecting with other apps, providing AI data analysis, streamlining business processes, and more?
      • Allow syncing Activities from other applications

        Marketing Automation could be a much more powerful platform if you were able to sync activities into the platform (e.g. purchase, donation, etc) outside of a user doing something on your website. I'd love it if you could sync Custom CRM Modules as activities,
      • Changing Corporate Structure - How Best to Adapt Current and Future Zoho Instances

        My current company is Company A LLC with a dba ("doing business as" - essentially an alias) Product Name B. Basically, Company A is the legal entity and Product Name B is what customers see, but it's all one business right now. We currently have a Zoho
      • how to add subform over sigma in the CRM

        my new module don't have any subform available any way to add this from sigma or from the crm
      • {"errors":[{"id":"500","title":"Servlet execution threw an exception"}]}

        Here's the call to move a file to trash. The resource_id is accurate and the file is present. header = Map(); header.put("Accept","application/vnd.api+json"); data = Map(); data_param1 = Map(); att_param1 = Map(); att_param1.put("status",51); data_param1.put("attributes",att_param1);
      • How to Install Zoho Workdrive Desktop Sync for Ubuntu?

        Hi. I am newbie to Linux / Ubuntu. I downloaded a tar.gz file from Workdrive for installing the Workdrive Desktop Sync tool. Can someone give me step by step guide on how to install this on Ubuntu? I am using Ubuntu 19.04. Regards Senthil
      • Integración Books para cumplir la ley Crea y Crece y Ley Antifraude (VeriFactu)

        Hola: En principio, en julio de 2025, entra en vigor la ley Crea y Crece y Ley Antifraude (VeriFactu). ¿Sabéis si Zoho va a cumplir con la ley para cumplir con la facturación electrónica conectada a Hacienda? Gracias
      • How to upload own video?

        How can you upload your own video on your zoho website? I do not want to use another host, but i want to insert my own files. how can i do this?
      • Support new line in CRM Multiline text field display in Zoho Deluge

        Hi brainstrust, We have a Zoho CRM field which is a Muti Line (Small) field. It has data in it that has a carriage return after each line: When I pull that data in via Deluge, it displays as: I'm hoping a way I can change it from: Freehand : ENABLED Chenille
      • A couple of minor enhancements to Workflows

        Last updated on September 17, 2024: These enhancements were initially available for early access, and we've now enabled them for all users. We are elated to announce a couple of enhancements to custom functions in our Workflows! Say hello to: "Source"
      • Announcing new features in Trident for Windows (v.1.32.5.0)

        Hello Community! Trident for Windows just got better! This update includes new features designed to improve and simplify email and calendar management—and it includes a feature you’ve been waiting for. Let’s dive into what’s new! Save emails in EML or
      • How to render either thumbnail_url or preview_url or preview_data_url

        I get 401 Unauthorised when using these urls in the <img> tag src attribute. Guide me on how to use them!
      • Next Page