Unselect a selection in a multi-select field

Unselect a selection in a multi-select field for multiple lead records without affecting any of its other selections at the click of a button.

A multi-select field allows users to select multiple options from a predefined list, making it easy to categorize and sort information. They are handy for tracking customer preferences, product interests, and other data to help businesses tailor their offerings to individual customers. However, what if you must remove a multi-select field selection for several contacts, leads, or other module records? Further, what if you need to do this without affecting any of the other selections in the multi-select field?

Using functions, you can unselect a selection in a multi-select field of a lead, contact, account, so on, without affecting any of its other selections. You can do this for one or several records using a custom button or workflow rule. Continue reading to learn how to accomplish this task in less than 15 minutes.

Permissions and availability

  • Users with the Modules Customization permission can create custom buttons.
  • Users with the Manage Extensibility permission can write custom functions.
  • Users with the Manage Sandbox permission can manage the sandbox.

Requirements

  • Create and link the button with the custom function, as detailed in the "Create Button" section below. Learn more
  • Test the function in a sandbox before deploying it in your production environment. Learn more

Create a button

  1. Navigate to Setup > Customization > Modules and Fields > Leads > Buttons > Create New Button.
  2. Provide a name for the button. For example: "Unselect a multi-select field selection".
    Add a description (optional).
  3. Choose the layout(s) you want the button to be placed.
  4. Specify the button's placement as In List and its position on the page as Mass Action Menu.
    You can also select In Record - Details to unselect a selection in individual lead records.
  5. Select the action to be performed as Writing Function.
  6. Provide a name and display name for the function, then click Create.
  7. In the Deluge script editor, do the following:
    1. Copy and paste the code provided below.
    2. Click Edit Arguments.
    3. Enter the name as leadId and select the value as Leads - Lead Id.
    4. Save the function.
  8. Select the profiles who can view this custom button.
  9. Click Save.
Create Button

The code

Code Copied
up = zoho.crm.getRecordById("Leads",leadId);
mul = up.get("fieldname").toList();
if(mul.contains("deleteselection"))
{
mul.removeElement("deleteselection");
upd = zoho.crm.updateRecord("Leads",leadId,{"fieldname":mul});
info upd;
}
return "Success";

Notes

  • Replace 'fieldname' with the API name of the multi-select picklist field.
  • Replace 'deleteselection' with the field's option you wish to unselect.
  • Make sure to use the accurate API name of the corresponding fields in the code snippet. Learn more
  • The above script is an example of unselecting a selection in a multi-select field of the leads module. By customizing the field name and parameters, you can modify this code to select or unselect a multi-select field selection in other modules.
  • You can customize the order of buttons on the list view page of the Leads module according to your preference. Learn more
  • To trigger this function with a workflow rule, delete the last line of the code snippet ("return 'Success'"). Learn more

Tips

  • Would you like to make a selection in a multi-select field without affecting other selections? If yes, use the parameter 'mul.add' in the code snippet.
  • Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.

Test the solution

  1. Click the Leads module and select the required list view.
  2. Select the lead records in which you want to unselect a selection in the multi-select field.
  3. Click the button you added to the list view page.
  4. Check whether the chosen records have the multi-select field choice unselected without affecting any of its other selections.

Did you find this useful? Try it out and let us know how it works. Share this with your team if they'd benefit from it! If you have questions, please don't hesitate to contact us.

More info

  • ModuleLeads
  • Trigger PointCustom Button
  • EditionEnterprise and above
  • ComplexityLow
  • Implementation Time15 minutes

Features used in the solution

Custom ButtonDeluge ScriptSandbox
Story Image

Looking for a custom solution?

Contact us, we will help enhance your productivity at lightning speed.

SUBMIT REQUEST

Developers: Share your solution with our community!