Kaizen Java SDK Version 5.0

Kaizen Java SDK Version 5.0

Hello, everyone! Welcome to another Kaizen week. In this post, we will discuss how third-party applications can integrate with Zoho CRM using Java SDK 5.0.

Use case 

Zylker is a real-estate app which can integrate with any CRM vendor and uses that data for it's use-cases. Zylker uses Java for the backend server code. Now they want to integrate with Zoho CRM.  How will they do it? Those users could be in different Zoho data centers like Europe (.eu), USA(.com), India(.in), Australia(.com.au) etc. With Zoho CRM's Java SDK 5.0, which consumes Zoho CRM v5 APIs, we can to do authorization and establish this integration. Zylker will write one common code and it should be usable for any CRM orgs across all DCs. 

Java SDK Project dependency

Include the Java dependency using either Maven or Gradle. The maven dependency is as below:

<repositories>
<repository>
<id>zohocrmsdk-5-0</id>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.zoho.crm</groupId>
<artifactId>zohocrmsdk-5-0</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>


If you are not using Maven or Gradle, please include the Zoho CRM Java SDK JAR and dependant JARs directly into the Java build path.

Setting up the OAuth client 

Create a Server-based Application in the corresponding API console page (https://www.zohoapis.{com/in/eu/com.au}). Enable "Multi-DC" under Settings of the app. Choose "Use the same OAuth credentials for all data centers". With this, you can use the same client ID, client secret, and redirect URI to authorize any Zoho account in any data center. Please refer to our previous posts to know more about domains and environments [Part -1] and [Part - 2].

Integrating the client with your application

In Zylker's web UI, there will be an option to integrate with Zoho CRM. The integration can be initiated from a link or a button containing the authorization URL, along with the corresponding client ID, state, redirect URI, and OAuth scopes. Once the user clicks on this link/button and completes the OAuth authorization process on Zoho, they will be redirected to the specified redirect URI with HTTP parameters location, code, accounts server, and state. These parameters can be utilized within the Java code logic of the redirect URI to begin using the Zoho CRM Java SDK.
The codes used in this post are hosted here for reference. We will focus on two distinct steps as mentioned below, for Zylker integration with Zoho CRM using Java SDK.
     1.  Authorize with Zoho CRM
     2. Fetching data from Zoho CRM

1. Authorize with Zoho CRM 

The aim of this step is to connect with the user's Zoho CRM and store the token details such as refresh token, access token and expiry time in the preferred datastore like MySQL, pgSQL etc. Once the user lands on the redirect URI after the OAuth2.0 authorization, we can extract the email of the logged-in user from zylker.com cookies. We also obtain the grant token and location from the redirect_uri of the authorization request. We pass these three values to the below integrateZohoCRM() function. This function takes care of creating a token for the connected Zoho CRM account and persisting it in the preferred datastore.


public static Boolean integrateZohoCRM(String location, String grant_token, String user_email) 
{
Boolean integrationStatus = Boolean.FALSE;
try {
Environment environment = DataCenter.get(location);
OAuthToken userToken = new OAuthToken.Builder()
                .clientID(OAuthClientDetails.CLIENT_ID)
                .clientSecret(OAuthClientDetails.CLIENT_SECRET)
                .grantToken(grant_token)
                .redirectURL(OAuthClientDetails.REDIRECT_URL)
                                 .userSignature(new UserSignature(user_email)) //email of the user who is trying to integrate with Zoho CRM          
                                 .build();
new Initializer.Builder().environment(environment).token(userToken).initialize(); 
integrationStatus = Boolean.TRUE;
    } catch (SDKException e) {
e.printStackTrace();
    } catch (Exception e) {
e.printStackTrace();
    }
return integrationStatus;
}

Refer here for the exact code section.

OAuthToken.Builder() creates a new instance of the builder for the OAuthToken class. It allows you to conveniently set up the necessary details for creating an OAuth token for authentication purposes. On passing the client ID, client secret, grant token, redirect URL, and user signature to the OAuthToken.Builder() method, we get the userToken object. One more important thing to note is that we have set the user signature as .userSignature(new UserSignature(user_email)) . This means that we are referring to the token uniquely by the email id of the logged-in Zylker user. The same signature should be used for any further operation to be done in Zoho CRM on behalf of this user.
Now that we have the OAuthToken object, we can send it to the Initializer class (as shown below) to create the refresh/access tokens and persist it.


 new Initializer.Builder().environment(environment).token(userToken).initialize(); 


As we haven't mentioned anything about where to do the persistence, by default the token details are persisted in a file named 'sdk_tokens.txt' using File Persistence. The content of the file would look like the following:


"id","user_name","client_id","client_secret","refresh_token","access_token","grant_token","expiry_time","redirect_url","api_domain" //Do not clear this default format, or else you will need  to generate a grant token again  in order to run the program.
"1","patricia@gmail.com","1000.xxxxx","xxxxxx","1000.xxxxxx.xxxx","1000.xxxxxxxxx.xxxxxxx","1000.xxxxxxxxx.xxxxxxx","1697370902510","https://www.zoho.com","https://www.zohoapis.com"



Apart from File Persistence, tokens can be persisted using Database persistence or Custom persistence.

Note

When Zoho introduces a new DC in future, it will be enough to update the project with the latest version of Zoho CRM Java SDK 5.0 and no further code change will be required. 

2. Fetching data from ZohoCRM

Once the integration is done, we can create OAuthToken with the user's email as UserSignature and call Zoho CRM Java SDK function. This will fetch the data specific to the user. The following fetchCRMData() function is a sample to fetch data from Zoho CRM.


public static void fetchCRMData(String email) throws Exception {
    OAuthToken userToken1 = new OAuthToken.Builder()
        .userSignature(new UserSignature(email))
        .build();
    new Initializer.Builder().token(userToken1).initialize();
    RecordOperations ro = new RecordOperations();
    ParameterMap paramInstance = new ParameterMap();
    List < String > fieldNames = new ArrayList < > (Arrays.asList("Company", "Email"));

    paramInstance.add(RecordOperations.GetRecordsParam.FIELDS, String.join(",", fieldNames));

    @SuppressWarnings("rawtypes")

    APIResponse response = ro.getRecords("Leads", paramInstance, null);

    .

    .

    .

}
 

Refer here for the exact code section.


In this example, we use the SDK's RecordOperations()  for retrieving records from the Leads module. This is done in the following steps:
  •  A new instance of RecordOperations is being created and assigned to the variable ro. This object handles operations related to records in Zoho CRM.  
  • ParameterMap instance is used to specify request parameters for the API calls. We can fetch the Company and the Email fields from the Leads module by passing them as the FIELDS parameter. 
  • We use the getRecords() method to make the API request via SDK, which fetches the respective CRM data.


We hope you found this post useful and interesting.  Stay tuned for more exciting posts.

Previous Kaizen Post : #107 Field Trackers in Zoho CRM

For more topics on Kaizen, please refer to our Kaizen collection here.







    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


                                                                                  Zoho Show Resources


                                                                                    Zoho Writer Writer

                                                                                    Get Started. Write Away!

                                                                                    Writer is a powerful online word processor, designed for collaborative work.

                                                                                      Zoho CRM コンテンツ






                                                                                        Nederlandse Hulpbronnen


                                                                                            ご検討中の方





                                                                                                  • Recent Topics

                                                                                                  • Task module and related-to field

                                                                                                    In modules other than the Task Module I can add several lookup fields to provide a variety of relationships. In the Task module lookup fields are not available. There is only one "related to" field which I want to use for Company. But I want to relate
                                                                                                  • Add Lookup Field in Tasks Module

                                                                                                    Hello, I have a need to add a Lookup field in addition to the ones that are already there in the Tasks module. I've seen this thread and so understand that the reason lookup fields may not be part of it is that there are already links to the tables (https://help.zoho.com/portal/en/community/topic/custom-fields-on-task-module).
                                                                                                  • migrating from Zoho Invoices (CRM) to Zoho Books

                                                                                                    Good day, I was wondering if there was a easy way to migrate all the quotes and invoices from Zoho Invoices CRM to Zoho Books. We plan to move to using Zoho Books in a few weeks and would like to have all the quotes and invoices from the past 3 years
                                                                                                  • Zoho MA and Custom Module

                                                                                                    I am trying to create a sync between Markting Automation and Zoho CRM. I am mapping a custom module from the CRM. The custom module has email field mobile phone field However I cannot finish the integration since the system keeps asking me for email or
                                                                                                  • When is partial reimbursement going to be launched?

                                                                                                    Hi there. I saw somewhere that the partial reimbursement feature is in the work. What is the update and ETA of that? Our clients and prospects have been asking us and we agree that that is an important feature to have.
                                                                                                  • Year-End Wrap: Declutter Your Inbox Using Email Filters

                                                                                                    Ping!—an email drops in. And another. And another! It's finally that time of the year when your inbox will be bursting with messages from team members, clients, and marketing agents, leaving you feeling overwhelmed and distracted. Sounds familiar? Now
                                                                                                  • Unified Notes View For Seamless Collaboration

                                                                                                    To facilitate better coordination among different departments and team members, the notes added to a record can now be accessed in all its associated records. With this, team members, from customer service representatives to field technicians, can easily
                                                                                                  • Q4 Europe In-person Zoho User Group Meetup: Streamlining Your Business Processes & Introduction to Zoho CRM for Everyone

                                                                                                    Hello Zoho Community, We are excited to announce our upcoming Zoho User Group meetup in Europe! This session is designed to help you streamline your business processes using Zoho CRM, with a special focus on enhancing customer interactions and leveraging
                                                                                                  • Formula fields - Request for dynamic recalculation / proper implementation

                                                                                                    Hi Guys, I have a big problem with Zoho formula fields. They don't recalculate each time the record is viewed - only when a record is edited. Formula fields should be updated dynamically each time a record is retrieved. As an example: I have a formula
                                                                                                  • Items attribute questions

                                                                                                    Many of my items have attributes, such as size and color. How can I add new fields to the "New Items" screen to capture that in my Purchase Orders, Items, and Sales Order pages? I only see these attribute fields when adding an Item Group. Also, on the
                                                                                                  • Organize and Track Phases with Phase Custom Views

                                                                                                    Phase Custom Views let you filter and display phases based on specific criteria. This helps you focus on what’s most relevant for you and your team. Filter phases using criteria such as budget, status, and more. Share views with specific users or teams
                                                                                                  • Record Asset Received as Payment

                                                                                                    How exactly would you account for this in books? For example, I receive a mini computer for a review and I get to keep it after the video is published. Would debit my normal asset account (e.g. Computers) and credit an income account (e.g. Other Income).
                                                                                                  • Invoice Line Item Report

                                                                                                    Is it possible to run an 'Invoice Line Item Report'? The 'Invoice Details Report' shows one row per invoice. I would like one row per Invoice Line Item.
                                                                                                  • Transform Your Customer Support with AI-Powered Chatbots in Zoho SalesIQ

                                                                                                    Ever wondered how some companies seem to have superhuman customer support? Let's uncover their secret! In the digital age, customer expectations are skyrocketing. Did you know that according to McKinsey, 75% of consumers expect a response within five
                                                                                                  • Progressive Invoicing

                                                                                                    Progressing invoicing is needed for many industries. It would be great to see it implemented into Zoho Books as well. Set up and send progress invoices in QuickBooks Desktop (intuit.com)
                                                                                                  • Client Script - mapping data from different module

                                                                                                    Dear ZOHO Team Firstly I need to describe the need - I need to have data from Contacts module based on lookup field - the 5 map limit is not enough for me because I have almost 20 fields to copy So I have decided to make a Customer Script - and from unknown
                                                                                                  • DORA compliance

                                                                                                    For DORA (Digital Operational Resilience Act) compliance, I’ll want to check if Zoho provides specific features or policies aligned with DORA requirements, particularly for managing ICT risk, incident reporting, and ensuring operational resilience in
                                                                                                  • Files Uploaded to Zoho WorkDrive Not Being Indexed by Search Engines

                                                                                                    Hello, I have noticed that the files I upload to Zoho WorkDrive are not being indexed by search engines, including Google. I’d like to understand why this might be happening and what steps I can take to resolve it. Here are the details of my issue: File
                                                                                                  • Zoho Creator Upcoming Updates - December 2024

                                                                                                    Hi all, We're excited to be back with the latest updates and developments on the Creator platform. Here's what we're going over this month: Deluge AI assistance Rapid error messages in Deluge editor QR code & barcode generator Expandable RTF and multi
                                                                                                  • Customer can't comment on SO or Invoice

                                                                                                    Hi I just saw that my customers are not able to submit a comment either on invoices or sales order. What happens if my customer hits submit is just nothing. only a red line appears on top of the page which probalby indicates an error. I'm not able to
                                                                                                  • Zoho Creator customer portal limitation | Zoho One

                                                                                                    I'm asking you all for any feedback as to the logic or reasoning behind drastically limiting portal users when Zoho already meters based on number of records. I'm a single-seat, Zoho One Enterprise license holder. If my portal users are going to add records, wouldn't that increase revenue for Zoho as that is how Creator is monetized? Why limit my customer portal to only THREE external users when more users would equate to more records being entered into the database?!? (See help ticket reply below.)
                                                                                                  • See Calendar When Creating Meetings On Record Page

                                                                                                    It would be a great user experience to see you calendar while you are creating a meeting on a record page. Here is how I imagine it could look:
                                                                                                  • Saved filters, layout rule support, related list quick navigation, and more

                                                                                                    Hello Everyone, We're excited to share some new features and enhancements in the Zoho CRM iOS and Android apps that will improve your mobile experience. These updates will make your CRM journey more efficient and user-friendly. Here's a look at what's
                                                                                                  • Power of Automation: Automatically send an email to all portal users with today's list of Open tasks.

                                                                                                    Hello Everyone, A Custom Function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as to when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it. Requirement:-
                                                                                                  • Introduction of Robotics Process Automation in Zoho products

                                                                                                    It will be great if Zoho can start advancing from automation to robotics process automation. For a start, it can be started with smart document understanding. Provide OCR engines Google cloud, Microsoft Azure Computer vision OCR, Microsoft OCR, Omnipage
                                                                                                  • Lock a custom field on a deal record but keep all other fields editable?

                                                                                                    I have a custom field, which auto-populates a job number upon converting a lead to a deal but the automation breaks if someone accidentally edits that field. I want to lock that field but keep all other fields open. Is this possible? I've tried through
                                                                                                  • Add Feature To Hide Plugin Sections On Record View

                                                                                                    Hi team, I'm trying to help a client tidy up their CRM. When it comes to record view some sections and fields are visible no matter what Layout Rules are applies and they are not removeable from the layout editor. I would like to see an option to hide
                                                                                                  • Creator Simplified #10: Predefine Form Field Values and Make Them Read-Only for Users

                                                                                                    Hey Creators, Ready for this week's tip in the Creator Simplified series? Today, we will explore how to have read only fields in a form. Use Case: Assume a scenario where the default value for a Department field needs to be English Literature, but you
                                                                                                  • Problem configuring/customizing sales pipeline steps

                                                                                                    Hello, I have created several sales pipelines with different stages in them. Unfortunately I forgot to properly configure these steps (conversion probability, forecast category). How can I modify and customize all these steps? Thnak you by advance M
                                                                                                  • fetch records from analytics table from creator

                                                                                                    I have a creator workflow that I am working in that will compare data from within the app to a table in zoho analytics. Is there a way to fetch a record from Analytics? I have attempted a custom connector with analytics and tried to use it with invoke
                                                                                                  • Directly Edit, Filter, and Sort Subforms on the Details Page

                                                                                                    Hello everyone, As you know, subforms allow you to associate multiple line items with a single record, greatly enhancing your data organization. For example, a sales order subform neatly lists all products, their quantities, amounts, and other relevant
                                                                                                  • Ability to Change Custom View After Cadence Creation

                                                                                                    Dear Zoho Team, I hope you are well. We would like to request an enhancement to the Cadence feature in Zoho CRM. Currently, during the creation of a Cadence, we can select a Custom View under the "Who is this for?" section. However, once the Cadence is
                                                                                                  • Zoho Creator Integration with QuickBooks: A Step-by-Step Guide

                                                                                                    Introduction: Integrating Zoho Creator with QuickBooks allows you to sync your business data between the two platforms, providing a seamless experience for managing accounting, invoicing, and financial data. This integration helps automate workflows and
                                                                                                  • Note not being pulled for other modules in email template

                                                                                                    Hi there, Currently i am creating an email template that is able to pull the data from notes field in estimate module and email it to procurement team where they will be able to receive the email with the contents of the note, i am unable to replicate
                                                                                                  • No Sales Returns on SO's with Dropped Shipped items + Inventory Items

                                                                                                    We have encountered an issue in Zoho related to sales orders that include both dropshipped items and inventory items. Specifically, it is currently not possible to create sales returns for the company’s own inventory items from these sales orders. This
                                                                                                  • Pre-fill TO and CC fields for Email Templates

                                                                                                    This would be a game changer to be able to set either specific email addresses or merge fields based on deal role titles into email templates. Please pass this along to *hopefully* add to future features of Zoho CRM.
                                                                                                  • Pick list - Cannot save list "Special Characters not Allowed" error message

                                                                                                    Bulk uploading values. All values are pretty standard - with the exception of a "-" (dash). Like:  Industry - Prepared Food Is the simple dash a special character too? Jan
                                                                                                  • Flow with CRM

                                                                                                    Hello, I have a simple flow that uses a web hook to enter data into a Sales Order. I have the web hook sending Flow data which has a PO field. If the PO has a special character like - or / or \ the task fails. How can I get the flow to be okay with the
                                                                                                  • Making the Resolution Tab Mandatory

                                                                                                    Hello Everyone! This edition is here to show you how to make the Resolution mandatory when closing a ticket. The Ticket Resolution tab helps keep a record of the solution provided for the ticket query. The resolution can serve as a quick reference to
                                                                                                  • Remove County field from Customer Address input screen (or allow input to be deleted)

                                                                                                    We are in the USA and have just noticed that there is now a County field in the Customer Address input screen (and maybe other areas of Zoho Books, but this is the one affecting us at the moment). County is not important to our business, and in fact we
                                                                                                  • Next Page