Kaizen #144 - Assigning values to different field types using Zoho CRM SDKs - Part II

Kaizen #144 - Assigning values to different field types using Zoho CRM SDKs - Part II



Welcome to another week of our Kaizen series! 

In our last week's Kaizen post, we explored the various field types in Zoho CRM and their typical uses. We also discussed the utility of our SDK sample codes available in our GitHub repositories and how they can be tailored to meet your specific needs. For effective implementation, understanding how to assign values to these different field types using the SDK is crucial, which remains our primary focus in this series.

Last week, we covered this topic using our JAVA SDK. This week, we will discuss assigning values using PHP SDK. To make sure you are all caught up, please revisit Part I before proceeding further.

2. PHP SDK

For more details, please refer to the GitHub repository for our latest PHP SDK. Check out the sample codes here.

Standard Fields:

a. Import the Field Class:
  1. use com\zoho\crm\api\record\{module_api_name};
b. Assign Values to Standard Fields: The syntax for assigning values to standard fields uses the addFieldValue method of the Record object:
  1. $record->addFieldValue({module_api_name}::{field_api_name}(), value);
Replace {module_api_name} and {field_api_name} with the appropriate values for your specific use case. 

Assigning values to Standard Fields:

Field Type
JSON Type
Assign Values Assign Null Value
text (single line)
string 
$record->addFieldValue(Leads::LastName(), "Boyle"); $record->addFieldValue(Leads::LastName(), null);
textarea (multiline)
string
$record->addFieldValue(Leads::Description(), "Specify your description") $record->addFieldValue(Leads::Description(), null);
email
string
$record->addFieldValue(Leads::Email(), "abc@zoho.com"); $record->addFieldValue(Leads::Email(), null);
phone
string
$record->addFieldValue(Leads::Phone(), "91(987)654321"); $record->addFieldValue(Leads::Phone(), null);
picklist
string
$record->addFieldValue(Leads::LeadStatus(), new Choice("Not Contacted")); --
date
string
$record->addFieldValue(Products::Sales_Start_Date(), new DateTime(2024, 6, 13).Date); $record->addFieldValue(Products::Sales_Start_Date(), null);
integer (number)
integer
$record->addFieldValue(Accounts::Employees(), 100); $record->addFieldValue(Accounts::Employees(), 100);
currency (double)
double
$record->addFieldValue(Leads::AnnualRevenue(), 10.00); $record->addFieldValue(Leads::AnnualRevenue(), null);
boolean (checkbox) boolean $record->addFieldValue(Leads::EmailOptOut(), true); --
website (URL)
string
$record->addFieldValue(Leads::Website(), "https://www.zoho.com"); $record->addFieldValue(Leads::Website(), null);

Custom Fields:

To manage custom fields using PHP SDK: a. Import the Record Class:
  1. use com\zoho\crm\api\record\Record;
  2. $record = new Record();
b. Assign Values to Custom Fields: The syntax for assigning values to standard fields uses the AddKeyValue method of the Record object:
  1. $record->addKeyValue("{field_api_name}", value);
Replace {field_api_name} with the appropriate values for your specific use case. 

Assigning values to Custom Fields:

Field Type
JSON Type
Assign Value
Assign Null Value
text (single line)
string 
$record->addKeyValue("Single_Line_Field", "Text Single Line");
$record->addKeyValue("Single_Line_Field", null);
textarea (multiline)
string
$record->addKeyValue("Multi_Line_Field", "Text Multi Line");
$record->addKeyValue("Multi_Line_Field", null);
email
string
$record->addKeyValue("Email_Field", "abc@zoho.com");
$record->addKeyValue("Email_Field", null);
phone
string
$record->addKeyValue("Phone_Field", "9900000000");
$record->addKeyValue("Phone_Field", null);
picklist
string
$record->addKeyValue("Pick_List_Field", new Choice("Option 1"));
$record->addKeyValue("Pick_List_Field", null);
multiselectpicklist
JSON array
$record->addKeyValue("Multi_Select_Field", [new Choice("Option 1"), new Choice("Option 2")]);
$record->addKeyValue("Multi_Select_Field", null);
date
string
$record->addKeyValue("Date_Field", (new \DateTime('2024-06-13')));
$record->addKeyValue("Date_Field", null);
datetime
string
$record->addKeyValue("Date_Time_Field", date_create("2024-06-20T11:10:00+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
$record->addKeyValue("Date_Time_Field", null);
integer (number)
integer
$record->addKeyValue("Number_Field", 12);
$record->addKeyValue("Number_Field", null);
currency (double)
double
$record->addKeyValue("Currency_Field", 10.25);
$record->addKeyValue("Currency_Field", null);
double
double
$record->addKeyValue("Decimal_Field", 12.25);
$record->addKeyValue("Decimal_Field", null);
percent 
double
$record->addKeyValue("Percent_Field", 12.25);
$record->addKeyValue("Percent_Field", null);
bigint (long integer)
string
$record->addKeyValue("Long_Integer_Field", "12345678");
$record->addKeyValue("Long_Integer_Field", null);
boolean (checkbox)
boolean
$record->addKeyValue("Checkbox_Field", true);
--
website (URL)
string
$record->addKeyValue("URL_Field", "https://www.zoho.com");
$record->addKeyValue("URL_Field", null);
lookup
JSON Object
$account = new Record();
$account->setId("3477061000023362051");
$record->addKeyValue("Lookup_Field", $account);
$record->addKeyValue("Lookup_Field", null);
multiselectlookup
JSON array
$record1 = new Record();
$linkingRecord = new Record();
$record1->addKeyValue("id", "3477061000023362051");
$linkingRecord->addKeyValue("Multi_Select_Lookup_Field", $record1);
$record->addKeyValue("Multi_Select_Lookup_Field", [$linkingRecord]);
$linkingRecord = new Record();
$linkingRecord->addKeyValue("_delete", true);
$linkingRecord->addKeyValue("id", "3477061000023557067");
$record->addKeyValue("Multi_Select_Lookup_Field", [$linkingRecord]);
userlookup
JSON object
$user = new MinifiedUser();
$user->setId("3477061000005791024");
$record->addKeyValue("User_Field", $user);
$record->addKeyValue("User_Field", null);
multiuserlookup
JSON array
$record1= new Record();
$linkingRecord = new MinifiedUser();
$linkingRecord->setId("3477061000005791024");
$record1->addKeyValue("MultiUser", $linkingRecord);
$record->addKeyValue("MultiUser", [$record1]);
$record1 = new Record();
$record1->addKeyValue("_delete", true);
$record1->setId("3477061000023553042");
$record->addKeyValue("MultiUser", [$record1]);
subform
JSON array
$subform = new Record();
$subform->addKeyValue("Name", "SDK");
$user1 = new MinifiedUser();
$user1->setId("3477061000018959001");
$subform->addKeyValue("User_Field", $user1);
$record->addKeyValue("Subform_Field", [$subform]);
$subform = new Record();
$subform->addKeyValue("_delete", true);
$subform->setId("3477061000023557086");
$record->addKeyValue("Subform_Field", [$subform]);
imageupload
JSON array
$imageUpload = new ImageUpload();
$imageUpload->setFileIdS("138ef2d9af5");
$record->addKeyValue("Image_Upload", [$imageUpload]);
$imageUpload = new ImageUpload();
$imageUpload->setDelete(null);
$imageUpload->setId("3477061000023579023");
$record->addKeyValue("Image_Upload", [$imageUpload]);
fileupload
JSON array
$fileDetail1 = new FileDetails();
$fileDetail1->setFileIdS("54957bcbc8fa685");
$record->addKeyValue("File_Upload", [$fileDetail1]);
$fileDetail1 = new FileDetails();
$fileDetail1->setDelete(null);
$fileDetail1->setId("3477061000023551042");
$record->addKeyValue("File_Upload", [$fileDetail1]);
multi_module_lookup
JSON Object
$record1 = new Record();
$record1->setId("3477061000021552002");
$module = array();
$module["id"] = "3477061000000002179";
$module["api_name"] = "Contacts";
$record1->addKeyValue("module", $module);
$record->addKeyValue("Appointment_For", $record1);
--


We trust this post has given you a better understanding of managing field data types in Zoho CRM using our PHP SDK. Remember that this learning does not end here. We have more posts coming up where we will explore handling field data types with our remaining SDK offerings. And do not forget to check out our Github for code samples.

As we strive for continuous improvement, we would love to hear your feedback. What topics would you like to see covered in our Kaizen series? Let us know in the comments or reach out to our support team at support@zohocrm.com.

Thank you for joining us this week. Happy coding and until next time!

Recommended Reads:




    Access your files securely from anywhere









                          Zoho Developer Community




                                                • Desk Community Learning Series


                                                • Digest


                                                • Functions


                                                • Meetups


                                                • Kbase


                                                • Resources


                                                • Glossary


                                                • Desk Marketplace


                                                • MVP Corner


                                                • Word of the Day


                                                • Ask the Experts





                                                          Manage your brands on social media



                                                                Zoho TeamInbox Resources



                                                                    Zoho CRM Plus Resources

                                                                      Zoho Books Resources


                                                                        Zoho Subscriptions Resources

                                                                          Zoho Projects Resources


                                                                            Zoho Sprints Resources


                                                                              Qntrl Resources


                                                                                Zoho Creator 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

                                                                                            Get Started. Write Away!

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

                                                                                              Zoho CRM コンテンツ






                                                                                                Nederlandse Hulpbronnen


                                                                                                    ご検討中の方




                                                                                                          • Recent Topics

                                                                                                          • Automatically Add Recurring Zoho Meeting Events to Zoho Calendar / Zoho Meeting Calendar

                                                                                                            Hello Zoho Meeting Team, Hope you are doing well. We would like to request an enhancement regarding recurring meetings created inside Zoho Meeting. At the moment, when we schedule a recurring meeting in Zoho Meeting, it does not appear in Zoho Calendar
                                                                                                          • Limited layout rules in a module

                                                                                                            There is a limit of 10 layout rules per module. Is there a way to get that functionality through different customization or workflow + custom function (easily accessible), etc. Having just 10 is limiting especially if module contains a lot of data. Are
                                                                                                          • Enhance Sign CRM integration

                                                                                                            Hello all, I'm working on a custom Deluge script to enhance the integration between Zoho CRM and Sign by using a writer merge template for additional flexibility. I want to replicate the post-sign document integration that exists between CRM and Sign
                                                                                                          • Python - code studio

                                                                                                            Hi, I see the code studio is "coming soon". We have some files that will require some more complex transformation, is this feature far off? It appears to have been released in Zoho Analytics already
                                                                                                          • Good news! Calendar in Zoho CRM gets a face lift

                                                                                                            Dear Customers, We are delighted to unveil the revamped calendar UI in Zoho CRM. With a complete visual overhaul aligned with CRM for Everyone, the calendar now offers a more intuitive and flexible scheduling experience. What’s new? Distinguish activities
                                                                                                          • Replacing email ID,

                                                                                                            In zoho sheets If I am sending it as an email attachments can I replace sender email ID from notifications to my email ID.
                                                                                                          • Move orders scan ISBN

                                                                                                            Hi We have ISBN setup to be searched in items zoho but move orders dissent recognize the ISBN is there q missing configuration? regards, JS
                                                                                                          • ViewID and Zoho Desk API

                                                                                                            I'm looking at the documentation for Listing contacts and it looks like you can filter by ViewID. I assume this is views created in a department or all departments. Is this correct? And if so, how do I find the ViewID for that view? EDIT: I see the view
                                                                                                          • Ability to Link Reported Issues from Zoho Desk to Specific Tasks or Subtasks in Zoho Projects

                                                                                                            Hi Zoho Desk Team, Hope you're doing well. When reporting a bug from Zoho Desk to Zoho Projects, we’ve noticed that it’s currently not possible to select an existing task or subtask to associate the issue with. However, when working directly inside Zoho
                                                                                                          • Automatically Update Ticket Status in Zoho Desk Based on Actions in Zoho Projects

                                                                                                            Hi Zoho Desk Team, Hope you’re doing well. We’re using the Zoho Desk–Zoho Projects integration to manage tasks related to customer tickets, and it works well for linking and tracking progress. However, there are a few important automation capabilities
                                                                                                          • Print Tickets

                                                                                                            We have field engineers who visit customers. We would like the option to print a job sheet with full details of the job and account/contact details.
                                                                                                          • Zoho Desk integration with Power BI

                                                                                                            Hi, I want to be able to create a Power BI report which has live updates of ticket data from zoho desk, is this possile at all? Thanks Jack
                                                                                                          • Ability to Attach Images When Reporting Issues to Zoho Projects from Zoho Desk

                                                                                                            Hi Zoho Desk Team, Hope you’re doing well. We’re using the Zoho Desk–Zoho Projects integration to report bugs directly from support tickets into the Zoho Projects issue tracker. This integration is extremely useful and helps us maintain smooth coordination
                                                                                                          • Ability to Choose Task List and Add Subtasks When Creating Tasks from Zoho Desk

                                                                                                            Hi Zoho Desk Team, Hope you’re doing well. We’re using the Zoho Desk–Zoho Projects integration to seamlessly connect customer tickets with project tasks. While the integration works great overall, we noticed two important limitations that affect our workflow
                                                                                                          • Sync Task Status from Zoho Projects to Zoho Desk

                                                                                                            Hi Zoho Desk Team, Hope you’re doing well. We’re actively using the Zoho Desk–Zoho Projects integration, which helps our support and project teams stay aligned. However, we noticed that when we change a task’s status in Zoho Projects, the change is not
                                                                                                          • Default/Private Departments in Zoho Desk

                                                                                                            1) How does one configure a department to be private? 2) Also, how does one change the default department? 1) On the list of my company's Zoho Departments, I see that we have a default department, but I am unable to choose which department should be default. 2) From the Zoho documentation I see that in order to create a private department, one should uncheck "Display in customer portal" on the Add Department screen. However, is there a way to change this setting after the department has been created?
                                                                                                          • Retainer invoice in Zoho Finance modlue

                                                                                                            Hello, Is there a way of creating retainer invoices in the Zoho Finance module? If not can I request this is considered for future updates please.
                                                                                                          • Can we do Image swatches for color variants?

                                                                                                            We want to do something like the attached screenshot on our new zoho store. We need image swatches instead of normal text selection. We want to user to select an image as color option. Is this doable? I don't see any option on zoho backend. Please h
                                                                                                          • How Zoho Desk contributes to the art of savings

                                                                                                            Remember the first time your grandmother gave you cash for a birthday or New Year's gift, Christmas gift, or any special day? You probably tucked that money safely into a piggy bank, waiting for the day you could buy something precious or something you
                                                                                                          • Zoho CRM IP Addresses to Whitelist

                                                                                                            We were told to whitelist IP addresses from Zoho CRM.  (CRM, not Zoho Mail.) What is the current list of IP Addresses to whitelist for outbound mail? Is there a website where these IP addresses are published and updated?  Everything I could find is over
                                                                                                          • Color of Text Box Changes

                                                                                                            Sometimes I find the color of text boxes changed to a different color. This seems to happen when I reopen the same slide deck later. In the image that I am attaching, you see that the colors of the whole "virus," the "irology" part of "virology," and
                                                                                                          • The difference between Zoho Marketing Automation and Zoho Campaigns

                                                                                                            Greetings Marketers! This post aims to differentiate between Zoho Marketing Automation and Zoho Campaigns. By the time you get to the end of the post, you will be able to choose a product that objectively suits you. What is Zoho Marketing Automation?
                                                                                                          • When moments in customer support get "spooky"

                                                                                                            It’s Halloween again! Halloween is celebrated with spooky symbols and meanings based on history and traditions, with each region adding its own special touch. While we were kids, we would dress up in costumes along with friends, attend parties, and enjoy
                                                                                                          • How to use Rollup Summary in a Formula Field?

                                                                                                            I created a Rollup Summary (Decimal) field in my module, and it shows values correctly. When I try to reference it in a Formula Field (e.g. ${Deals.Partners_Requested} - ${Deals.Partners_Paid}), I get the error that the field can’t be found. Is it possible
                                                                                                          • Zoho Mail Android app update - View emails shared via Permalink on the app.

                                                                                                            Hello everyone! In the latest version(v2.8.2) of the Zoho Mail Android app update, we have brought in support to access the emails shared via permalink within the app. Earlier, when you click the permalink of an email, you'll be redirected to a mobile
                                                                                                          • Let us view and export the full price books data from CRM

                                                                                                            I quote out of CRM, some of my clients have specialised pricing for specific products - therefore we use Price Books to manage these special prices. I can only see the breakdown of the products listed in the price book and the specialised pricing for
                                                                                                          • Weekly Tips: Manage External Images in Zoho Mail

                                                                                                            When you receive emails every day, whether from clients, newsletters, or services, many of them contain external images that automatically load when you open the message. While this can make emails look more engaging, it can also impact your privacy and
                                                                                                          • Empowered Custom Views: Cross-Module Criteria Now Supported in Zoho CRM

                                                                                                            Hello everyone, We’re excited to introduce cross-module criteria support in custom views! Custom views provide personalized perspectives on your data and that you can save for future use. You can share these views with all users or specific individuals
                                                                                                          • How to display Motivator components in Zoho CRM home page ?

                                                                                                            Hello, I created KPI's, games and so but I want to be able to see my KPI's and my tasks at the same time. Is this possible to display Motivator components in Zoho CRM home page ? Has someone any idea ? Thanks for your help.
                                                                                                          • Introducing Record Summary: smarter insights at your fingertips

                                                                                                            Hello everyone, We’re excited to introduce the Record Summary feature. This powerful addition makes use of Zia to simplify how you interact with your CRM data, providing a seamless, consolidated view of critical record information. Scrolling through the
                                                                                                          • Account in Quick View Filter

                                                                                                            I have a report that I often run against a specific Account. Every time, I have to go into the edit menu and change the Advanced Filter. I would prefer to use the Quick View Filter, but it does not allow me to use the one and only field that makes any
                                                                                                          • Insert Cookie Policy in Zoho Sites

                                                                                                            Hello, i need to insert a banner on my site because i'm in Italy so i have to respect EU laws for Cookie Policy and Privacy Policy. I see that i need to insert a code in <head> section of my site to show a banner/popup with cookie info. How i can do this? Thank you Luca
                                                                                                          • Cliq iOS can't see shared screen

                                                                                                            Hello, I had this morning a video call with a colleague. She is using Cliq Desktop MacOS and wanted to share her screen with me. I'm on iPad. I noticed, while she shared her screen, I could only see her video, but not the shared screen... Does Cliq iOS is able to display shared screen, or is it somewhere else to be found ? Regards
                                                                                                          • Unable to confirm Super Admin assignment — confirmation button not working

                                                                                                            I’m trying to change the roles within my organization. I am currently a super admin and would like to add another user as a super admin. When I attempt to confirm the action, a screen appears asking for my password to verify my identity. However, when
                                                                                                          • Delegates should be able to delete expenses

                                                                                                            I understand the data integrity of this request. It would be nice if there was a toggle switch in the Policy setting that would allow a delegate to delete expenses from their managers account. Some managers here never touch their expense reports, and
                                                                                                          • Let's Talk Recruit: Meet Zia, your all-in-one AI assistant (Part-2)

                                                                                                            Welcome back to Let’s Talk Recruit series. In Part 1, we introduced Zia and how AI is reshaping the way recruiters work. This time, we’re taking a closer look at how far Zia has come and how each update continues to simplify your everyday tasks. When
                                                                                                          • Function #9: Copy attachments of Sales Order to Purchase Order on conversion

                                                                                                            This week, we have written a custom function that automatically copies the attachments uploaded for a sales order to the corresponding purchase order after you convert it. Here's how to configure it in your Zoho Books organization. Custom Function: Hit
                                                                                                          • stock

                                                                                                            bom/bse : stock details or price =STOCK(C14;"price") not showing issue is #N/A! kindly resolve this problem
                                                                                                          • Kaizen #8 - Handling Recurrence and Participants in the Events Module via API

                                                                                                            Hello everyone! We are back this week with an exciting post—Handling recurrence and participants in the Events module through API. First things first—What is the Events module? "Events" is a part of the Activities module in Zoho CRM.  An event is an activity that happens at a given place and time. You can find Events on the user's Zoho CRM's home page, Activities home page, Calendar, and in other related records. What are the types of Events? Events are of two types—Recurring and non-recurring events.
                                                                                                          • Marketer’s Space - Get Holiday-Ready with Zoho Campaigns

                                                                                                            Hello marketers, Welcome back to another post in Marketer’s Space! Q4 is packed with opportunities to connect with your audience - from Halloween, Black Friday, and Cyber Monday, to Thanksgiving, Christmas, and New Year. In this post, we’ll look at how
                                                                                                          • Next Page