Kaizen #28 - Use cases related to Record Owner

Kaizen #28 - Use cases related to Record Owner

Hello everyone!
Welcome back to another week of Kaizen!
In this post, we will discuss a few use cases related to the Record Owner field.

Who is a record owner?
A record owner is a user of a CRM org who owns a record in a module. Any other user could have also created or owned this record, previously.

This "owner" is a lookup field that points to the resource Users. Therefore, when you use this field, it must always be a JSON object in your input.

The following are a few use cases related to the record owner field:
  1. Assigning a lead owner while inserting a record
  2. Updating the lead owner
  3. Automatically changing the record owner

1. Assigning a lead owner while inserting a record
You can use the Insert Records API to insert a record and assign that record to a user simultaneously. 

Details required
      a. Record ID of the owner you want to assign the record to.
     b. API Name and field type of the owner field to use in the input.

a. Record ID of the Owner
To assign an owner to a record, you must know the ID of the owner.
Make a GET Users API call to fetch the list of all users in your org.

Request URL: {{api-domain}}/crm/v2/users
Request method: GET

Here is a snippet of the response.



The "id" key represents the unique ID of the user record.

b. API Name and field type of the owner field to use in the input
API Name
You can find the API name of the owner field in two ways

i.  From the UI
     1. Go to Setup > Developer Space > APIs > API Names > Choose the module.
     2. For Leads, the API Name of the Lead Owner field is Owner.
      

ii. Through API
      1. Make a GET Fields Metadata API call to the desired module.
      2. Search for the field label Lead Owner in the response.
      3. The value of the key api_name represents the API Name of the Lead Owner field.
      4. The value of the key json_type represents the type of the JSON input you must pass for that field.
      Here, the Lead Owner field accepts data as a JSON object.
      

Now that we have the required details, let us see how to construct the input body to insert a lead and assign the owner of that lead record.
Last_Name is the system-defined mandatory field in the Leads module.
Owner is a JSON Object.

Request URL: {{api-domain}}/crm/v2/Leads
Request method: POST

Sample Input

{
 "data": [
  {
 
  "Last_Name": "Kaizen #28",
  "Email": "newcrmapi1@abc.com",
  "Owner":{
  "id":"3652397000000281001"//Record ID of the user from the GET Users API
  }
  }
 ]
}

Here is the response.



Let us now GET the Lead we just created to check the Owner.

Request URL: {{api-domain))/crm/v2/Leads/3652397000002043003
Request method: GET

Here is the response.



As you can see, the Lead is assigned to the owner.

Note
If you do not specify the owner, the system assigns the current user as the owner of the record.

2. Updating the record owner
You can use the Update Records API to update the owner of multiple records, or the Update a Specific Record API to update the owner of a single record.

As discussed in the above section, the Owner field is a JSON object.

Here is a sample input.


{
    "data": [
        {
            "Owner": {
                "id": "3652397000000186017"//Record ID of the new owner
            }
        }
    ]
}


3. Automatically changing the Record Owner
In CRM, while record creation, the system assigns the current user as the owner of a record, by default. If you want to assign leads to other owners automatically without the need to pass the Owner details in the API, you can write a custom function to achieve the same.

Your custom function must have the logic to assign owners to records based on the desired criteria.
Therefore, whenever a lead is created in CRM, it must trigger the custom function that assigns the lead to the right owner.

Round Robin assignment is one of the solutions to this.



We hope you found this post useful. Let us know your thoughts in the comment section, or write to us at support@zohocrm.com.

Cheers!







    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