Businesses typically follow custom approval processes to manage sales orders upon creation. For example, approval may depend on whether the applied discount complies with the company's pricing policy. If an approver finds that the discount exceeds the allowed limit, they can reject the sales order and auto-update the Discount Status field to indicate this rejection.
As part of this workflow, they may want to disable certain actions, such as viewing a print preview, exporting to PDF, and sending via Zoho Sign, until the approver has approved the sales order and the Discount Status field has been marked as approved. This approach helps prevent salespeople from accidentally sending premature contracts or distributing unofficial versions of sales orders.
However, if you take a cursory look at your CRM, you may notice that there are no options to disable these actions in the sales order interface for specific profiles or users. So how can you restrict key actions until they're approved? Our low-code tools are handy in this scenario.
Using a combination of a custom field and a client script, you can disable these actions in browsers whenever you load a sales order in your CRM. So whenever your salespeople open a sales order, the client script checks the value of the Discount Status field, and if it says Declined, the script will automatically disable buttons like Send with Zoho Sign, Print Preview, and Export to PDF. Read on to learn more.
Permissions and availability
- Users with the Modules Customization permission can add custom fields.
- Users with the Manage Extensibility permission can create client scripts.
- Users with the Manage Sandbox permission can manage the sandbox.
Requirements
- Add a Picklist field to the Sales Orders module. This picklist field will indicate whether the discount applied to the sales order was approved or declined. Learn more
- Create a client script that triggers upon loading the details page of a sales order. Learn more
- Test the function in a sandbox environment before deploying it to your production environment. Learn more
Add a custom field
The first step is adding the custom picklist field to the Sales Orders module.
- Navigate to Setup > Customization > Modules and Fields.
- Click the Sales Orders module to open the layout editor.
- Drag and drop the Picklist field from the New Fields tray to the desired section of the layout.
- Name the picklist field (e.g., "Discount Status"), enter the options (e.g., "Approved" and "Declined"), and define its properties as required.
- Once you've finished, select Done, then click Save and Close.
Create a client script
The next step is to create a client script in your Zoho CRM account:
- Navigate to Setup > Developer Hub > Client Script > +New Script.
- Provide a name for the script. For example: "Disable sales order actions".
- Add a description (optional).
- In the Category Details section, do the following:
- Category - Choose Module.
- Page - Choose Detail Page.
- Module - Choose Sales Orders.
- Choose the layout.
It can be Standard or any other custom layout of the Sales Orders module.
- In the Event Details section, do the following:
- Type - Choose Page Event
- Event - Choose onLoad.
- Click Next.
The Client Script IDE will open. - Copy and paste the script provided below.
You can customize the script, if needed. - Click Save and Close to save the client script.
The code
var did = $Page.record_id;
var em = $Crm.user.email;
if ((em == "user1@domain.com" || em == "user2@domain.com") || (em == "user3@domain.com" || em == "user4@domain.com") || (em == "user5@domain.com" || em == "user6@domain.com") || (em == "user7@domain.com" || em == "user8@domain.com"))
{
var field = ZDK.Page.getField('Discount_Status').getValue();
if (field == "Declined")
{
ZDK.Page.getButtons().find(a => a.getLabel() === "Send with Zoho Sign").disable();
ZDK.Page.getButtons().find(a => a.getLabel() === "Print Preview").disable();
ZDK.Page.getButtons().find(a => a.getLabel() === "Export to PDF").disable();
}
}Notes
- Make sure you update the script with the accurate API name of the corresponding fields (e.g., "Discount Status"). Learn more
- Replace the placeholder email addresses with those of your salespeople for whom the sales order actions should be disabled. You can include any number of email addresses in the same pairing format.
- You can disable other sales order actions (e.g., "Send Email") by including them in the code snippet.
- The above script is an example of disabling specific actions on the sales order detail page to prevent salespeople from accidentally sending a premature or unofficial version of the sales order. You can use this client script code for any other module, such as Deals or custom modules, by modifying the module name and parameters.
Tip
- Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.
Test the solution
- Log in to Zoho CRM using the email address specified in the client script.
- Navigate to the Sales Orders module.
- Open the sales order record whose Discount Status field was updated as Declined through the approval process.
The client script will be triggered when the details page is loaded. - Check whether the buttons Send with Zoho Sign, Print Preview, and Export to PDF are disabled.
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
- ModuleSales Orders
- Trigger PointBrowser
- EditionEnterprise and above
- ComplexityMedium
- Implementation Time30 minutes

Looking for a custom solution?
Contact us, we will help enhance your productivity at lightning speed.
SUBMIT REQUEST