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



                                                            • Sticky Posts

                                                            • Kaizen #226: Using ZRC in Client Script

                                                              Hello everyone! Welcome to another week of Kaizen. In today's post, lets see what is ZRC (Zoho Request Client) and how we can use ZRC methods in Client Script to get inputs from a Salesperson and update the Lead status with a single button click. In this
                                                            • Kaizen #222 - Client Script Support for Notes Related List

                                                              Hello everyone! Welcome to another week of Kaizen. The final Kaizen post of the year 2025 is here! With the new Client Script support for the Notes Related List, you can validate, enrich, and manage notes across modules. In this post, we’ll explore how
                                                            • Kaizen #217 - Actions APIs : Tasks

                                                              Welcome to another week of Kaizen! In last week's post we discussed Email Notifications APIs which act as the link between your Workflow automations and you. We have discussed how Zylker Cloud Services uses Email Notifications API in their custom dashboard.
                                                            • Kaizen #216 - Actions APIs : Email Notifications

                                                              Welcome to another week of Kaizen! For the last three weeks, we have been discussing Zylker's workflows. We successfully updated a dormant workflow, built a new one from the ground up and more. But our work is not finished—these automated processes are
                                                            • Kaizen #152 - Client Script Support for the new Canvas Record Forms

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


                                                            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

                                                                                                              • Adding custom "lookup" fields in Zoho Customization

                                                                                                                How can I add a second “lookup” field in Zoho? I’m trying to create another lookup that pulls from my Contacts, but the option doesn’t appear in the module customization sidebar. In many cases, a single work order involves multiple contacts. Ideally,
                                                                                                              • CRM x WorkDrive: We're rolling out the WorkDrive-powered file storage experience for existing users

                                                                                                                Release plan: Gradual rollout to customers without file storage add-ons, in this order: 1. Standalone CRM 2. CRM Plus and Zoho One DCs: All | Editions: All Available now for: - Standalone CRM accounts in Free and Standard editions without file storage
                                                                                                              • Canvas Detail View Related List Sorting

                                                                                                                Hello, I am having an issue finding a way to sort a related list within a canvas detail view. I have sorted the related list on the page layout associated with the canvas view, but that does not transfer to the canvas view. What am I missing?
                                                                                                              • Windows Desktop App - request to add minimization/startup options

                                                                                                                Support Team, Can you submit the following request to your development team? Here is what would be optimal in my opinion from UX perspective: 1) In the "Application Menu", add a menu item to Exit the app, as well as an alt-key shortcut for these menus
                                                                                                              • Ability for admin to access or make changes in zoho form without asking for ownership

                                                                                                                Currently in zoho form only form owner can make the changes in the form and if someone else has to make changes then we have to transfer the ownership to them and even admin also cant access it . So i think admin must have the ability or option to access
                                                                                                              • Issue with WhatsApp Template Approval and Marketing Message Limit in Zoho Bigin

                                                                                                                We are facing issues while creating and using WhatsApp message templates through Zoho Bigin, and we request your clarification and support regarding the same. 1. Utility Template Approval Issue Until December, we were able to create WhatsApp templates
                                                                                                              • Zoho CRM Calendar View

                                                                                                                Hello Zoho team, We need desperately a calendar view next to list, kandan and other views. I think it should be easy to implement as you already have the logic from Projects and also from Kanban View in CRM. In calendar view when we set it up - we choose
                                                                                                              • Camera

                                                                                                                I can sign on to a meeting and see the other participants, but my screen is dark. The instructions for Zoho "Camera Settings" say "click on lock icon in address bar," but I don't see that icon! Suggestions?
                                                                                                              • What is Workqueue and how to hide it?

                                                                                                                Hi, My CRM suddenly have this "Workqueue", may I ask how to set the permission of this tab?
                                                                                                              • Introducing Workqueue: your all-in-one view to manage daily work

                                                                                                                Hello all, We’re excited to introduce a major productivity boost to your CRM experience: Workqueue, a dynamic, all-in-one workspace that brings every important sales activity, approval, and follow-up right to your fingertips. What is Workqueue? Sales
                                                                                                              • Batch/lot # and Storage bin location

                                                                                                                Hi I want to ask for a feature on Zoho inventory I own a warehouse and I've gone through different management software solutions with no luck until I found Zoho, it has been a game changer for my business with up to the minute information, I'm extremely happy with it. It's almost perfect. And I say Almost because the only thing missing for me (and I'm sure I'm not alone) is the need of being able to identify the lot number of my inventory and where it is located in the warehouse. Due to the nature
                                                                                                              • Adding Sender Address with Basic Plan

                                                                                                                According to the knowledge base, I should be able to add Sender addresses with the Basic Plan. But whenever I try to add an email, it takes me to a search window and I cannot find any emails in the list. Even mine, which is the admin. email.
                                                                                                              • Conditional Field Visibility in Bigin CRM

                                                                                                                I would like to request support for conditional field visibility within Bigin CRM. This feature should allow administrators to configure show/hide rules for fields based on predefined criteria (e.g., field values, picklist selections, stage changes,
                                                                                                              • Bill automation in Zoho Books

                                                                                                                Hi I am looking for 3rd-party options for bill automation in zoho which are economical and preferably have accurate scanning. What options do I have? Zoho's native scanning is a bit pricey
                                                                                                              • Reporting Tags

                                                                                                                We've been using reporting tags for years (before itemizing was available) and now we are finding reporting these tags are impossible to track. Reports have changed in the customization and our columns of reporting tags no longer show up. We do not use
                                                                                                              • Function #53: Transaction Level Profitability for Invoices

                                                                                                                Hello everyone, and welcome back to our series! We have previously provided custom functions for calculating the profitability of a quote and a sales order. There may be instances where the invoice may differ from its corresponding quote or sales order.
                                                                                                              • Consumption based inventory

                                                                                                                I am currently using Zoho Books for my hospitality business, which includes lodging and restaurant services. We purchase many items in bulk for storage and consumption as needed. I'd like these items to be recorded as inventory when purchased and categorized
                                                                                                              • Smarter Access Control: Role-Based Access vs. Responsibility-Based Profiles

                                                                                                                Every business has roles, responsibilities, and workflows. While roles help define structure, responsibilities within those roles are rarely the same. As your team grows, some members need access to only a specific set of features. Others require visibility
                                                                                                              • Partner with HDFC And Sbi Bank.

                                                                                                                Hdfc and sbi both are very popular bank if zoho books become partner with this banks then many of the zoho books users will benefit premium features of partnered banks.
                                                                                                              • API in E-Invoice/GST portal

                                                                                                                Hi, Do I have to change the api in gst/e-invoice portal as I use zoho e books for my e-invoicing. If yes, please confirm the process.
                                                                                                              • Member role in zoho meeting

                                                                                                                does a user with member role can see other users in the organization
                                                                                                              • Mail Merge is not working properly as far as the AUTOMATE section is concerned

                                                                                                                Hi there, I created a Mail Merge template for the Deal module. I would like Deal owners to mail merge their Deal records, download the Mail Merge document as a Word doc and make a few changes before sending it to the customer. Thing is, neither the "Merge
                                                                                                              • Clone Recurring Expenses

                                                                                                                Our bookkeeping practices make extensive use of the "clone" feature for bills, expenses, invoices, etc. This cuts down significantly on both the amount of typing that needs to be done manually and, more importantly, the mental overhead of choosing the
                                                                                                              • Zoho Books - How to Invoke a Custom Function in Schedulers

                                                                                                                We have multiple schedulers that send emails to customers in batches. Currently, we are maintaining the same code across several schedulers. Is it possible to use a custom function inside a scheduler script? If yes, how can we invoke the custom function
                                                                                                              • Workqueue

                                                                                                                I really like the idea of the Workqueue generally - it will be really useful. What it seems to lack however, is the ability to customise it properly. I want to be able to show a custom view rather than just "My Leads" and "Leads Assigned in Last 3 hours".
                                                                                                              • Importing into Multiselect Picklist

                                                                                                                Hi, We just completed a trade show and one of the bits of information we collect is tool style. The application supplied by the show set this up as individual questions. For example, if the customer used Thick Turret and Trumpf style but not Thin Turret,
                                                                                                              • Special characters (like â, â, æ) breaking when input in a field (encoding issue)

                                                                                                                Hey everyone, We are currently dealing with a probably encoding issue when we populate a field (mostly but not exclusively, 'Last Name' for Leads and Contracts). If the user manually inputs special characters (like ä, â, á etc.) from Scandinavian languages,
                                                                                                              • Set Custom Icon for Custom Modules in new Zoho CRM UI

                                                                                                              • Portals-Adjust Column Sizes

                                                                                                                I am trying to adjust the column widths in Portals tabs. Columns that don't need to be wide are wide and longer ones are very short. I thought adding more to the digits box in Edit would widen them, but it doesn't. Anyone know how to adjust these?
                                                                                                              • 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. Latest update
                                                                                                              • is there any way to change the "chat with us now" to custom message?

                                                                                                                is there any way to change the "chat with us now" to custom message? I want to change this text
                                                                                                              • Introducing Connected Records to bring business context to every aspect of your work in Zoho CRM for Everyone

                                                                                                                Hello Everyone, We are excited to unveil phase one of a powerful enhancement to CRM for Everyone - Connected Records, available only in CRM's Nextgen UI. With CRM for Everyone, businesses can onboard all customer-facing teams onto the CRM platform to
                                                                                                              • Notes badge as a quick action in the list view

                                                                                                                Hello all, We are introducing the Notes badge in the list view of all modules as a quick action you can perform for each record, in addition to the existing Activity badge. With this enhancement, users will have quick visibility into the notes associated
                                                                                                              • Is Zoho Live Chat compatible with WordPress CMS?

                                                                                                                Hello, I have a website called www.jjrlab.com and I'm interested in using Zoho Chat on it. Does it support WordPress CMS? Thanks.
                                                                                                              • Using email "importance" as workflow-criteria

                                                                                                                I'd like to set up a workflow that triggers if an incoming email has been flagged as "high importance" but I'm not seeing any way to do that. Hopefully I'm just missing something obvious...?
                                                                                                              • Introducing spam detection for webforms: An additional layer of protection to keep your Zoho CRM clean and secure

                                                                                                                Greetings all, One of the most highly anticipated feature launches—Spam Detection in webforms—has finally arrived! Webforms are a vital tool for record generation, but they're also vulnerable to submissions from unauthenticated or malicious sources, which
                                                                                                              • Bring your CRM and Desk app inside SalesIQ with widgets

                                                                                                                Have you ever been confused and frustrated with multiple open tabs and switching back and forth from SalesIQ to other apps to perform your business-specific operations? How effective would it be to have all the required tools and data of the apps you
                                                                                                              • Password Assessment Reports for all users

                                                                                                                I'm the super admin and looking at the reporting available for Zoho Vault. I can see that there is a Password Assessment report available showing the passwords/weak and security score by user. However I'm confused at the 'report generated on' value. Monitor
                                                                                                              • Speak Your Customers' Language: SalesIQ's chatbots now support 30 languages 🤖

                                                                                                                We're unveiling some major upgrades to our chatbot that are set to revolutionize your experience! Now SalesIQ support 30 languages for both Zobot and Answer bot. By speaking your customers' language, you can enhance engagement, improve customer satisfaction,
                                                                                                              • record submitted from creator and invoice is creating in books , but the workflow of books is not tiggering on create of record in books

                                                                                                                record submitted from creator and invoice is creating in books , but the workflow of books is not tiggering on create of record in books headermap = Map(); headermap.put("X-ZOHO-Execute-CustomFunction","true"); response_inv = invokeurl [ url :"https://www.zohoapis.com/books/v3/invoices/fromsalesorder?salesorder_id="
                                                                                                              • Next Page