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

    • Currency abbreviations

      Hello, Im stuck, and need help. I need the currency fields for example, opportunity value, or total revenue, to be abbreviated, lets say for 1,000 - 1K, 1,000,000 - 1M, and so on, how should I do this?
    • Losing description after merging tickets

      Hello, We merge tickets when they are about the same topic from the same client. It happens sometimes. We recently noticed that after the merger only the description from the master ticket is left in a thread. And the slave-ticket description is erased.
    • in the Zoho Creator i have File Upload field get the file on submission of the form Get the File and upload to Zoho Books

      in the Zoho Creator i have File Upload field get the file on submission of the form Get the File and upload to Zoho Books . how I get the file From zoho creator and upload to Zoho Books . using Api response = invokeUrl [ url: "https://www.zohoapis.com/creator/v2.1/data/hh/l130/report/All_Customer_Payments/"+input.ID
    • Generate a link for Zoho Sign we can copy and use in a separate email

      Please consider adding functionality that would all a user to copy a reminder link so that we can include it in a personalized email instead of sending a Zoho reminder. Or, allow us to customize the reminder email. Use Case: We have clients we need to
    • Syntax for URLs in HTML Snippets

      What are some best practices for inserting a URL in an HTML snippet? I've looked at Zoho Help articles on navigation-based and functional-based URLs, but I'm still unclear on how to incorporate them in an HTML snippet. For example, 1. How do I link to
    • 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
    • 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?  
    • Rate Limiting in Zoho Flow (OpenAI API)

      Hi Everyone, We are facing some issues when using Zoho Flow as we have a deluge script running which is making external calls to OpenAI endpoint. Sometimes the response takes more than 30 seconds meaning the script will timeout. We want to implement a
    • Placing a condition before converting the LEAD

      Hi,  I need some assistance with Lead conversion. I need to place certain conditions before allowing the user to convert the lead.  For example: up until the certain status's doesn't equal "green" don't allow to convert lead.  I tried creating this using
    • it is possible to open a widget via deluge script function

      I have one function that is workflow action I call my fucntion I need to call the internal widget it is possible to open or it have to please tell me the solution
    • Creator - Portal Custom Domain

      I will pay $100 in crypto to anyone who can actually get my Creator Custom Domain to function (actually tell me how you got yours to).  Domain verifies, Nothing. I've been fighting it a week, multiple chats to customer service. Clearly I'm doing something wrong.  Some datapoints Domain name itself unimportant, can be a string of numbers.  I need to know what registrars are working for you because GoDaddy does NOT.  Do I need hosting? I've tried both ways and nothing works.  I pushed through Cloudflare
    • Translation support expanded for Modules, Subforms and Related Lists

      Hello Everyone!   The translation feature enables organizations to translate certain values in their CRM interface into different languages. Previously, the only values that could be translated were picklist values and field names. However, we have extended
    • Transitioning to API Credits in Zoho Desk

      At Zoho Desk, we’re always looking for ways to help keep your business operations running smoothly. This includes empowering teams that rely on APIs for essential integrations, functions and extensions. We’ve reimagined how API usage is measured to give
    • steps and options to change Domain DNS/Nameservers settings

      Please share the options or steps to change  Domain DNS/Nameservers settings 
    • Unable to explore desk.zoho.com

      Greetings, I have an account with zoho which already has a survey subscription. I would like to explore desk.zoho.com, but when I visit it while logged in (https://desk.zoho.com/agent?action=CreatePortal) I just get a blank page. I have tried different
    • Employees in Leave Policy exceptions

      In the Leave Policies we should be able to add specific employees to the exception list So it will be like All Employees except A,B,C in the exception list, currently we can only add departments etc
    • 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
    • Transition Criteria Appearing on Blueprint Transitions

      On Monday, Sept. 8th, the Transition criteria started appearing on our Blueprints when users hover over a Transition button. See image. We contacted Zoho support because it's confusing our users (there's really no reason for them to see it), but we haven't
    • Meet Canvas' Grid component: Your easiest way to build responsive record templates

      Visual design can be exciting—until you're knee-deep in the details. Whether it's aligning text boxes to prevent overlaps, fixing negative space, or simply making sure the right data stands out, just ironing out inconsistencies takes a lot of moving parts.
    • Unified task view

      Possible to enable the unified task view in Trident, that is currently available in Mail?
    • How I set default email addresses for Sales Orders and Invoices

      I have customers that have different departments that handle Sales Orders and Invoices. How can i set a default email for Sales Orders that's different than the default email for Invoices? Is there a way I can automate this using the Contact Persons Departments
    • Modular Permission Levels

      We need more modular Permissions per module in Books we have 2 use cases that are creating problems We need per module export permission we have a use case where users should be able to view the sales orders but not export it, but they can export other
    • When dispatched to crew, assigning lead missing

      Hello, For the past two or three weeks, whenever an officer assigns Service Appointment to a team, the lead person is missing from the assigned service list. Therefore, we have to reschedule the SA and then the lead person becomes visible in the assigned
    • Kaizen #157: Flyouts in Client Script

      Hello everyone! Welcome back to another exciting edition of our Kaizen series, where we explore fresh insights and innovative ideas to help you discover more and expand your knowledge!In this post, we'll walk through how to display Flyouts in Client Script
    • Bigin, more powerful than ever on iOS 26, iPadOS 26, macOS Tahoe, and watchOS 26.

      Hot on the heels of Apple’s latest OS updates, we’ve rolled out several enhancements and features designed to help you get the most from your Apple devices. Enjoy a refined user experience with smoother navigation and a more content-focused Liquid Glass
    • How get stock name from other column ?

      How get stock name from other column ? e.g. =STOCK(C12;"price") where C12 is the code of the stock
    • Adding a developer for editing the client application with a single user license

      Hi, I want to know that I as a developer I developed one application and handed over to the customer who is using the application on a single user license. Now after6 months customer came back to me and needs some changes in the application. Can a customer
    • Archiving Contacts

      How do I archive a list of contacts, or individual contacts?
    • Download an email template in html code

      Hello everyone, I have created an email template and I want to download it as html. How can i do that? I know you can do it via the campaigns-first create a campaign add the template and download it as html from there. But what if i don't want to create
    • Attachment is not included in e-mails sent through Wordpress

      I have a Wordpress site with Zeptomail Wordpress plugin installed and configured. E-mails are sent ok through Zeptomail but without the included attachment (.pdf file) Zeptomail is used to send tickets to customers through Zeptomail. E-Mails are generated
    • Upcoming Changes to the Timesheet Module

      The Timesheet module will undergo a significant change in the upcoming weeks. To start with, we will be renaming Timesheet module to Time Logs. This update will go live early next week. Significance of this change This change will facilitate our next
    • Best way to schedule bill payments to vendors

      I've integrated Forte so that I can convert POs to bills and make payments to my vendors all through Books. Is there a way to schedule the bill payments as some of my vendors are net 30, net 60 and even net 90 days. If I can't get this to work, I'll have
    • Cant update image field after uploading image to ZFS

      Hello i recently made an application in zoho creator for customer service where customers could upload their complaints every field has been mapped from creator into crm and works fine except for the image upload field i have tried every method to make
    • Billing Management: #4 Negate Risk Free with Advances

      In the last post, we explored how unbilled charges accumulate before being invoiced. But what happens when businesses need money before service begins? Picture this: A construction company takes on a $500,000 commercial building project expected to last
    • Importing data into Assets

      So we have a module in Zoho CRM called customers equipments. It links to customers modules, accounts (if needed) and products. I made a sample export and created extra fields in zoho fsm assets module. The import fails. Could not find a matching parent
    • CRM templates

      Hello everyone, In my company we use Zoho campaigns where we set up all newsletters and we use Zoho CRM for transactional emails. I have created some templates in Zoho campaigns but from my understanding i cannot use those in Zoho CRM, right?
    • Is there an equivalent to the radius search in RECRUIT available in the CRM

      We have a need to find all Leads and/or Contacts within a given radius of a given location (most likely postcode) but also possibly an address. I was wondering whether anyone has found a way to achieve this in the CRM much as the radius search in RECRUIT
    • Zoho CRM Inventory Management

      What’s the difference between Zoho CRM’s inventory management features and Zoho Inventory? When is it better to use each one?
    • Cannot Enable Picklist Field Dependency in Products or Custom Modules – Real Estate Setup

      Hello Zoho Support, I am configuring Zoho CRM for real estate property management and need picklist field dependency: What I’ve tried: I started by customizing the Products module (Setup > Modules & Fields) to create “Property Type” (Housing, Land, Commercial)
    • How to add application logo

      I'm creating an application which i do not want it to show my organization logo so i have changed the setting but i cannot find where to upload/select the logo i wish to use for my application. I have seen something online about using Deluge and writing
    • Next Page