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

        • {"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);
        • Converting Sales Order to Invoice via API; Problem with decimal places tax

          We are having problems converting a Sales Order to an Invoice via API Call. The cause of the issue is, that the Tax value in a Sales Order is sometimes calculated with up to 16 decimal places (e.g. 0.8730000000000001). The max decimal places allowed in
        • Zoho Canvas - Custom templates for related lists

          Hi, I see that the example pages load always one of our related lists in a custom template, but I dont know how to work with that:  1) How can i make my own custom templates for related lists?  2) Where and how can i check out existing custom templates?
        • Kaizen #147 - Frequently Asked Questions on Zoho CRM Widgets

          Heya! It's Kaizen time again, folks! This week, we aim to address common queries about Zoho CRM Widgets through frequently asked questions from our developer forum. Take a quick glance at these FAQs and learn from your peers' inquiries. 1. Where can I
        • 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?"
        • 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.
        • Zohom mail

          Plz resolve the problem . I hope u understand .
        • Clients not receiving emails

          I've been informed that my emails are not being received. Is there anything that I should look into to rectify this? Many thanks!
        • 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
        • 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 ?
        • Bharat

          a
        • 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
        • 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?
        • 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
        • 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
        • 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
        • 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!
        • Zoho CRM Calendar | Custom Buttons

          I'm working with my sales team to make our scheduling process easier for our team. We primary rely on Zoho CRM calendar to organize our events for our sales team. I was wondering if there is a way to add custom button in the Calendar view on events/meeting
        • Max numbr of IMAP Accounts in Zoho Mail?

          In Zoho mail, you can manage the inboxes of other accounts using IMAP (and POP, actually) https://www.zoho.com/mail/help/external-imap-accounts.html Is there a max to the number of inboxes we can add?
        • Create Lead Button in Zoho CRM Dashboard

          Right now to create Leads in the CRM our team is going into the Lead module, selecting the "Create Lead" button, then building out the lead. Is there anyway to add the "Create Lead" button or some sort of short cut to the Zoho CRM Dashboard to cut out
        • Searching customer field

          Hello, When entering a receipt, we select customer information. The customer information is synced with Zoho CRM. However, we can't find the customer information because it searches for words that begin with the entered value. It needs to search for words
        • Introducing Version-3 APIs - Explore New APIs & Enhancements

          Happy to announce the release of Version 3 (V3) APIs with an easy to use interface, new APIs, and more examples to help you understand and access the APIs better. V3 APIs can be accessed through our new link, where you can explore our complete documentation,
        • Zoho CRM Tracking Google Enhanced Conversions

          Can anyone @Zoho, consultants, or users help me understand if Zoho CRM is going to support Google's Enhanced Conversions? I included some information from Google below about it. We use Google Adwords for our pay per click advertising for lead generation,
        • zoho click, and nord VPN

          Unfortunately, we've been having problems with Zoho Click, where essentially the line cuts off after about a minute's worth of conversation every time we are on VPN. Is there a way we can change this within the settings so it does not cut the line off
        • Connecting Portals from different Zoho apps

          Hi, I note that Zoho has functionality for customer portals for several of the Zoho apps, like CRM, Projects, Desk etc. Is there any way to connect these portals?  It would be great if we could give our customers access to a portal in which they could
        • Billing Management: #5 Usage Billing

          After understanding the nuances of Advance Billing and Retainers, we will explore one of the booming billing models. Long ago, villagers drew water from a shared well in a small village. The well was a lifeline for the entire community. Ravi, the well
        • Next Page