Kaizen 145 Assigning values to different field types using Zoho CRM SDKs Part III

Kaizen 145 Assigning values to different field types using Zoho CRM SDKs Part III



Welcome to another Kaizen week!

In Part I of our series, we explored the various field types in Zoho CRM in detail and demonstrated how to assign values to these fields using our Java SDK. In Part II, we continued by showing you how to work with these field types using our PHP SDK.

This week, in Part III, we will discuss in detail on assigning values to different field types using our Python SDK. If you missed our previous posts, we recommend checking out Part I and Part II before moving forward. 

3. Python SDK

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

Standard Fields:

a. Import the Field Class:
  1.       from zohocrmsdk.src.com.zoho.crm.api.record import Record
  2.       record = Record()

b. Assign Values to Standard Fields: The syntax uses the add_field_value method of the Record object:
  1.       record.add_field_value(Field.{module_api_name}.{field_api_name},value);
Field Type
JSON Type
Assign Value
Assign Null Value
text (single line)
string 
record.add_field_value(Field.Leads.last_name(), "Last Name");
record.add_field_value(Field.Leads.last_name(), None);
textarea (multiline)
string
record.add_field_value(Field.Leads.description(), "Add your description here");
record.add_field_value(Field.Leads.description(), None);
email
string
record.add_field_value(Field.Leads.email(), "abc@zoho.com");
record.add_field_value(Field.Leads.email(), None);
phone
string
record.add_field_value(Field.Leads.phone(), "91(987)654321");
record.add_field_value(Field.Leads.phone(), None);
picklist
string
record.add_field_value(Field.Leads.lead_status(), Choice("Not Contacted"));
record.add_field_value(Field.Leads.lead_status(), None);
date
string
record.add_field_value(Field.Products.support_start_date(), datetime.date(2023, 6, 20));
record.add_field_value(Field.Products.support_start_date(), None);
datetime
string
record.add_field_value(Field.Calls.call_start_time(), datetime.datetime(2023, 11, 20, 10, 00, 1));
record.add_field_value(Field.Calls.call_start_time(), None);
integer (number)
integer
record.add_field_value(Field.Accounts.employees(), 100);
record.add_field_value(Field.Accounts.employees(), None);
currency (double)
double
record.add_field_value(Field.Leads.annual_revenue(), 10.00);
record.add_field_value(Field.Leads.annual_revenue(), None);
boolean (checkbox)
boolean
record.add_field_value(Field.Leads.email_opt_out(), True);
record.add_field_value(Field.Leads.email_opt_out(), None);
website (URL)
string
record.add_field_value(Field.Leads.website(), "https://www.zoho.com");
record.add_field_value(Field.Leads.website(), None);

Custom Fields:

To manage custom fields using Python SDK:
a. Import the Record Class:
  1. from zohocrmsdk.src.com.zoho.crm.api.record import Record
  2. record = Record()
b. Assign Values to Custom Fields: The syntax for assigning values to standard fields uses the add_key_value method of the Record object:

  1.       record.add_key_value("{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.add_key_value("Single_Line_Field", "Text Single Line 15");
record.add_key_value("Single_Line_Field", None);
textarea (multiline)
string
record.add_key_value("Multi_Line_Field", "Text Multi Line Field");
record.add_key_value("Multi_Line_Field", None);
email
string
record.add_key_value("Email_Field", "abc@zoho.com");
record.add_key_value("Email_Field", None);
phone
string
record.add_key_value("Phone_Field", "9900000000");
record.add_key_value("Phone_Field", None);
picklist
string
record.add_key_value("Pick_List_Field", Choice("Option 1"));
record.add_key_value("Pick_List_Field", None);
multiselectpicklist
JSON array
record.add_key_value("Multiselect_Field", [Choice("Option 1"), Choice("Option 2")])
record.add_key_value("Multi_Select_Field", None);
date
string
record.add_key_value("Date_Field", datetime.date(2023, 6, 20));
record.add_key_value("Date_Field", None);
datetime
string
record.add_key_value("Date_Time_Field", datetime.datetime(2023, 11, 20, 10, 00, 1));
record.add_key_value("Date_Time_Field", None);
integer (number)
integer
record.add_key_value("Number_Field", 12);
record.add_key_value("Number_Field", None);
currency (double)
double
record.add_key_value("Currency_Field", 10.25);
record.add_key_value("Currency_Field", None);
double
double
record.add_key_value("Decimal_Field", 12.25);
record.add_key_value("Decimal_Field", None);
percent 
double
record.add_key_value("Percent_Field", 12.25);
record.add_key_value("Percent_Field", None);
bigint (long integer)
string
record.add_key_value("Long_Integer_Field", 12345678);
record.add_key_value("Long_Integer_Field", None);
boolean (checkbox)
boolean
record.add_key_value("Checkbox_Field", True);
record.add_key_value("Checkbox_Field", None);
website (URL)
string
record.add_key_value("URL_Field", "https://www.zoho.com");
record.add_key_value("URL_Field", None);
lookup
JSON Object
account =.Record();
account.set_id(3477061000023362051);
record.add_key_value("Lookup_Field", account);
record.add_key_value("Lookup_Field", None);
multiselectlookup
JSON array
multi_select_list = []
record = Record()
record.add_key_value("id", 44024800152)
linking_record = Record()
linking_record.add_key_value("MultiSelectLookup", record)
multi_select_list.append(linking_record)   
record.add_key_value("MultiSelectLookup", multi_select_list)
multi_select_list = []
record = Record()
record.add_key_value("id", 4402493052)
linking_record = Record()
linking_record.add_key_value("MultiSelectLookup", record)
multi_select_list.append(linking_record)   
record.add_key_value("MultiSelectLookup", None)
userlookup
JSON object
user = MinifiedUser() 
user.set_id(3477061005791024)
record.add_key_value("User_Field", user)
record.add_key_value("User_Field", None)
multiuserlookup
JSON array
multiuser = []
record = Record();
linking_record = MinifiedUser()
linking_record.set_id(34770005791024)
record.add_key_value("MultiUser", linking_record)
multiuser.append(record)
record.add_key_value("MultiUser", multiuser)
multiuser = []
record = Record()
linking_record = MinifiedUser()
linking_record.set_id(347700005791024)
record.add_key_value("MultiUser", linking_record)
multiuser.append(record)
record.add_key_value("MultiUser", None)
subform
JSON array
subformList = []
subform = Record()
subform.add_key_value("Name", "SDK")
user1 = MinifiedUser();
user1.set_id(3477061000018959001)
subform.add_key_value("User_Field", user1)
subformList.append(subform)
record.add_key_value("Subform_Field", subformList)
subformList = []
subform = Record()
subform.add_key_value("Name", "SDK")
user1 = MinifiedUser();
user1.set_id(3477061000018959001)
subform.add_key_value("User_Field", user1)
subformList.append(subform)
record.add_key_value("Subform_Field", None)
imageupload
JSON array
image_upload = ImageUpload()
image_upload.set_file_id__s("ae94shudf7")
record.add_key_value("Image_Upload", [image_upload])
image_upload = ImageUpload()
image_upload.set_file_id__s("a184e4b87")
record.add_key_value("Image_Upload", None)
fileupload
JSON array
fileDetails = []
fileDetail1 = FileDetails()
fileDetail1.set_file_id__s("ed425d797bc");
fileDetails.append(fileDetail1)
record.add_key_value("File_Upload", fileDetails);
fileDetails = []
fileDetail1 = FileDetails()
fileDetail1.set_file_id__s("ed45d797bc");
fileDetails.append(fileDetail1)
record.add_key_value("File_Upload", None);
multi_module_lookup
JSON Object
record1 = Record()
record1.set_id(3477061000021552002)
module = dict()
module["id"] = "3477061000000002179"
module["api_name"] = "Contacts"
record1.add_key_value("module", module)
record.add_key_value("Appointment_For", record1)
--


We hope that this series has helped you gain a deeper understanding of managing different field types in Zoho CRM using our Java, PHP and Python SDKs. In the next part of this series, we will discuss about managing fields using our remaining SDK offerings. 

In the meantime, if you have any questions regarding field management with our SDKs, feel free to share them in the comments below, or send us an email at support@zohocrm.com. Your feedback is invaluable to us. 

We appreciate you joining us on this learning journey. Stay tuned for more informative and developer-centric posts in our Kaizen series every Friday!



Recommended Reads:









      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 WorkDrive Resources



                                                                      Zoho Campaigns Resources


                                                                        Zoho CRM Resources

                                                                        • CRM Community Learning Series

                                                                          CRM Community Learning Series


                                                                        • Tips

                                                                          Tips

                                                                        • 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