Kaizen #78 : How to disable clone record?

Kaizen #78 : How to disable clone record?

Hello everyone!
Welcome back to another interesting Kaizen post.
In this post, let us discuss a workaround solution for the use case - How to disable clone record for a user.

Requirement

Consider that you want to disable the clone option for the Deals module for all users other except the users with Administrator profile.



Solution

We don't have a straightforward option to disable the clone button that appears on every module. If a profile is given "create" access to a module, then the user with that profile will be able to clone the record also. But in real time, there are high chances for an approved record to get cloned by the user, which cannot be permitted. The ultimate aim is that any user other than the users having an Administrator profile should not be allowed to save a cloned record. 

Currently there are two possible ways to prevent a cloned record from getting saved.

1. Prevent record saving when the user clicks Save button.
2. Disable save button for clone Page.

1. Prevent record saving when the user clicks save button.
  • To achieve this, you need to create a Client Script for the clone page of the Deals module with onSave Page Event.
  • Go to Setup > Developer Space > Client Script. Click +New Script.
  • Specify the details to create a script and click Next.

  • Enter the following script and click Save.


var user = ZDK.Apps.CRM.Users.fetchById($Crm.user.id);
if (user.profile.name != 'Administrator') {
      ZDK.Client.showAlert('Hi '+user.first_name+' ' +user.last_name+', you do not have the access to clone this deal. Contact your Administrator');
      return false;
  }


  • Here is how the Client Script works.


Thus the user can no longer save a cloned record when you implement this workaround solution. In addition to the above, you can also add an alert message when the clone Deal record gets loaded, (i.e) before the user enters value to the fields in the clone record. So that the user will be aware that he cannot save the cloned record.

 2. Disable save button for clone page
  • You can disable the save button in Clone page using Client Script. 
  • To achieve this, you need to create a Client Script for the clone page of the Deals module with onLoad Page Event.
  • Go to Setup > Developer Space > Client Script. Click +New Script.
  • Specify the details to create a script and click Next.

  • Enter the following script and click Save.

var user = ZDK.Apps.CRM.Users.fetchById($Crm.user.id);
if (user.profile.name != 'Administrator') {
var save_btn = ZDK.Page.getButton('record_save');
save_btn.disable();
}

  • Here is how the above Client Script works.


Note:
In the upcoming release of Client Script, you will be able to disable the clone button directly in the Detail page (Standard) of any module based on custom criteria.

We hope you found this post useful. We will meet you next week with another interesting topic!
If you have any questions let us know in the comment section.
Click here for more details on Client Script in Zoho CRM.


Related Links

    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