Update a form using custom action (from another form's report)

Update a form using custom action (from another form's report)

Requirement  

Update a form using a custom action configured in another form's report.

Use Case

In an engineering college student management application, a student may withdraw at any time of the academic year. Whenever a student applies for withdrawal, it should update the record of the student with the relevant details.  

See how it works

Steps to follow

1. Create the forms with the following details:
Form
Form Link Name
Field Type
Field Name
Field Link Name
Add Student
Add_Student
Email
Email
Email
Name
Student Name
Student_Name
Date
Date Of Birth
Date_Of_Birth
Single Line
Department
Department
Single Line
Course
Course
Drop Down
  • 2017-2021
  • 2018-2022
  • 2019-2023
  • 2020-2024
  • 2021-2025
Academic Year
Academic_Year
Drop Down
  • Active (Mark as default)
  • Inactive
  • Passed-out
Student Status
Student_Status
Multi line
If inactive, please enter proof of leaving
If_inactive_please_enter_proof_of_leaving
Date
Date Of Leaving
Date_Of_Leaving
Leaving Request
Leaving_Request
Lookup (Add_Student)
Student
Student
Date ( Initial Value - zoho.currentdate)
Request Date
Request_Date
Multi-line
Reason for leaving
 
Reason_for_leaving
Decision Box
Approved
Approved
Decision Box
Rejected
Rejected
 
Now, we shall hide the If inactive, please enter proof of leaving and Date Of Leaving fields and show them if the student status becomes Inactive. Set the Reason for leaving field in the Leaving Request form as Mandatory.
 
2. Create a workflow to hide the above two fields if the Student Status value is not Inactive.
 
3. Click Add New Action and enter the below code in the Deluge Editor:
  1. if(Student_Status != "Inactive")
  2. {

  3. //Hide the below fields if the Student Status is not inactive
  4.  hide If_inactive_please_enter_proof_of_leaving;
  5.  hide Date_Of_Leaving;
  6. }
This will hide the inactive fields when the form loads.
 
Only a student can raise the Leaving Request. So, let's create a workflow during the load of the Leaving Request to fetch the details of the current logged-in student and to disable it, so that there is no modification.
 
4. Next, let's create a workflow during the load of the Leaving Request form.
 
5. Click Add New Action and add the below code to find the current logged-in student.
  1. //Get the corresponding Add_Student record from the login details
  2. input.Add_Student = Add_Student[Email == zoho.loginuserid].ID;

  3. //Disable the field to prevent further modification
  4. disable Add_Student;

An action item will be created for every record in the Leaving Request form, which will allow for approval of the corresponding request and mark the student as Inactive.
 
6. We will list only the relevant records to the administrators. Add a filter to the Leaving Request report to show only those Leaving Requests that are not Approved.
 
7. Next, let's add a report workflow for the administrators to approve the Leaving Request for a student. Click on the Leaving Request report. Click Quick View. Navigate to Configure Fields > Add Fields > Add New Button. Name the Action Item 'Approve Leaving Request'.
 
8. We shall execute this action item after confirmation. Add the following confirmation message:
  1. Execute the Approve Leaving Request action for this record for this student -  ${Add_Student.Student_Name} ?

9. Name the workflow 'Leaving Requestand click Create Workflow.

10. Click Add New Action > Deluge Script > Create your own. Add the below Deluge code to update the leaving details in the Add Student form:
  1. //Fetch the corresponding Add_Student record
  2. student = Add_Student[ID == input.Add_Student];

  3. //Set the Date Of Leaving to the current date
  4. student.Date_Of_Leaving=zoho.currentdate;

  5. //Assing the Reason for Leaving 
  6. student.If_inactive_please_enter_proof_of_leaving=input.Reason_for_Leaving;

  7. //Mark the Student Status as Inactive
  8. student.Student_Status="Inactive";

  9. //Mark the current Leaving Request record to Approved
  10. input.Approved = true;

11. Let's add another script to send an email to the student once the Leaving Request is approved. Click Add New Action > Deluge Script > Create your own. Add the below Deluge code to notify:
  1. sendmail
  2. [
  3.  from :zoho.adminuserid
  4.  to :input.Add_Student.Email
  5.  subject :"Your Leaving Request is approved!"
  6.  message :"<div><br>Hi " + input.Add_Student.Student_Name + "<br/>We are so sorry to let you go. Your request is approved.</div>"
  7. ]

12. Click Create. This will create the action item.
 
13. Although optional, we can create an action item for rejecting the Leave Request in a similar fashion. We can set the Rejected field value accordingly and explain the reason for rejection in an email.

See how it works