Display action button for specific records

Display action button for specific records

Requirement  

The customized action button in a report should be visible only for certain records, based on a condition.

Use Case  

An asset request app lets employees raise requests for gadgets or machines. While filling the form, employees can specify if the request has been discussed with their manager. If the request has not been discussed, the buttons Approve and Reject are displayed for the manager. If the request has already been discussed, the buttons are disabled.

Steps to follow  

  1. Create three forms with the following details:
Form
Form Link Name
Field Type
Field Name
Field Link Name
Employees and Managers
Employees_and_Managers
Email
Employee Email
Employee_Email
Email
Manager Email
Manager_Email
Asset Request
Asset_Request
Email
Email
Email
Email
Manager Email
Manager_Email
Single Line
Asset Required
Asset_Required
Decision Box
Checked with Manager
Checked_with_Manager
Managers Approval
Managers_Approval
Email
Employee Email
Employee_Email
 
 
Email
Manager Email
Manager_Email
 
 
Single Line
Requested Asset
Requested_Asset
 
 
Decision Box
Discussed with Manager
Discussed_with_Manager
 
The Employees and Managers form contains the details of employees and their respective managers. The Asset Request form is used by employees to raise asset requests.The Managers Approval form is used by managers to approve or reject the asset requests.
  1. Let's create a workflow to set the employee's email address to the email field when the Asset Request form loads. Based on the employee's email address, we will also set the manager's email address. Create a workflow with the following details :

The workflow is to be triggered when the Asset Request form loads, so we are selecting the Form Event as Load of the Form.
  1. Click Add New Action.
  1. Save the following Deluge snippet in the Deluge editor:
  1. //set the logged in employee's email address as the Email field value
  2. input.Email = zoho.loginuserid;

  3. //fetch and assign the manager's email address from Employees and Managers form based on the current employee
  4. input.Manager_Email = Employees_and_Managers[Employee_Email == input.Email].Manager_Email;
  1. Now, let's create a workflow to pass the asset request records to the Managers Approval form. The manager can approve or reject the asset request. Create a workflow with the following details:
The record must be created in the Manager's Approval form once a record is successfully submitted in the Asset Request form. Hence, we are selecting Form Event as Successful form submission.
  1. Click Add New Action and select Deluge Script.
  1. Save the following Deluge snippet in the Deluge editor:
  1. //set the logged in employee's email address as the Email field value
  2. input.Email = zoho.loginuserid;

  3. //fetch and assign the manager's email address from Employees and Managers form based on the current employee
  4. input.Manager_Email = Employees_and_Managers[Employee_Email == input.Email].Manager_Email;
  1. Now, let's add a filter in the Managers Approval report so that each manager can view only their reporting employee's details. Click Open Report Properties fo r the Managers Approval report.
  1. Add the following filter. The system variable zoho.loginuserid represents the email address of the login user.
The above filter will only display records that contain the logged-in manager's email address.
Now that everything is set up, let's create the Approve and Reject buttons. We will also add a condition to only display it when the employee has not discussed the asset request earlier.
  1. Select Managers Approval report > Quick View > Actions, and click +.  
 
  1. Create an action item with the following details :
 
  1. Click Create Workflow to add instructions as to what should happen when the request is approved. For example, you can use the send mail task to send an email to the employee and the IT team saying the request is approved.
 
  1. Similarly, create another action item with the following details.
 
  1. Click Create Workflow to add instructions as to what should happen when the request is rejected. For example, you can use the send mail task to send an email to the employee and the IT team saying the request is rejected.
  1. Now, let's display the buttons in the report. Navigate to Manager's Approval Report > Configure fields for Web.
 
  1. Add the Approve and Reject buttons.
 

See how it works  

 

  Points to Note  

  • The email addresses can be disabled to ensure employees do not edit the email values.
  • You can add your managers and employees in the application and share only relevant app components using permissions. For example, the manager should only be able to view the Managers Approval form, or the employees should only be able to view the Asset Request form.