Update an existing record using stateless forms

Update an existing record using stateless forms

Requirement  

Use details specified in a stateless form to modify records in the main form.

Use Case  

In an order management system, a customer has placed an order and wants to cancel it. The administrators allow for cancellation by accepting the reason and updating the same in the current record. However, the other fields cannot be updated. So, we get the values of the required fields for cancellation and update the main order record.

Steps to follow  

1. Create the forms with the following details:
Form
Form Link Name
Field Type
Field Name
Field Link Name
New Order
New_Order
Email
Contact Email
Contact_Email
Date
Order Date
Order_Date
Subform
  • Single Line
  • Number
  • Currency
  • Currency
Products
  • Product Name
  • Quantity
  • Rate
  • Sub-Total
Products
  • Product_Name
  • Quantity
  • Rate
  • Sub_Total
 
Currency
Total
Total
Drop Down
  • Pending
  • Ready to Deliver
  • Delivered
  • Cancelled
Order Status
Order_Status
Date
Cancellation Date
Cancellation_Date
Multi-line
Reason
Reason
Cancellation
Cancellation ( Duplicate this form to create a stateless form named Cancel Request )
Date ( Initial Value : zoho.currentdate )
Cancellation Date
Cancellation_Date
Number
Order ID
Order_ID
Multi-line
Reason (Mandatory)
 
Reason

Mark the
Order Status field as admin only We shall add the
  • Cancellation Date  
  • Reason fields
to the New Order form to a section named Cancellation.
 
2. Let's create a workflow to execute during the load of the New Order form to hide the Cancellation section.
 
3. Add the below code in the Deluge Editor:
  1. hide Cancellation; 

4. We will display Cancel Request form when the customer chooses to cancel an order placed. So, let's hide this form from sections.
 
5. Only the user who placed an order can cancel one. This is why we are creating a report to list only those orders created by the logged-in user. Create a list report from the New Order form and name it as Your Orders.
 
6. Add a filter to the Your Orders report to display only the orders for the current login user and active orders - with Order Status value Pending or Ready to Deliver or Delivered.
 
7. Next, let's add a report workflow to allow for the customers to cancel an order. Click on the My Orders report. Navigate to Quick View > Add Field > Add New Button. Name the Action Item as 'Cancel Order'.
 
8. An order can be cancelled if it is not delivered. So, set the criteria to show the action item if the Order Status value is not Delivered.
 
9. We shall execute this action item after confirmation. Add a confirmation message accordingly as below.
 
10. Name the workflow as 'cancelOrder' and click Create Workflow.
 
11. Click Add New Action > Deluge Script > Create your own. Add the below deluge code to open the stateless form Cancel Request in a popup window with the Order ID value equal to the current record ID. This is done to ensure the correct order is cancelled by the user.
  1. openUrl( "#Form:Cancel_Request?Order_ID=" + ID, "popup window", "height=300px,width=300px");

12. Click Create. This will create the action item.

Now that the report workflow is configured, let us configure the functioning of the Cancel Request stateless form.
 
13. Let's create a workflow on the load of the Cancel Request to disable the Cancellation Date and hide the Order ID fields so that they are not modified.
 
14. Click on Add New Action and add the below script to disable the Cancellation Date and hide the Order ID fields.
  1. disable Cancellation_Date;
  2. hide Order_ID; 

15. Once this Cancel Request form is filled and submitted, the corresponding New Order record should be updated too. W e shall create a workflow to execute when the Submit button is clicked on the Cancel Request form.
 
16. Click Add New Action > Deluge Script. Add the below Deluge Script in the editor:
  1. //Closing the Cancel Request stateless form popup
  2. openUrl("#Script:page.parent.refresh ","parent window");

  3. //Get the corresponding New Order record
  4. order = New_Order[ID == input.Order_ID];

  5. //Update the Reason field
  6. order.Reason=input.Reason;

  7. //Update the Cancellation Date field
  8. order.Cancellation_Date=input.Cancellation_Date;

  9. //Update the Order Status to Cancelled
  10. order.Order_Status = "Cancelled";

17. Additionally, we can create a report to show the cancelled orders alone too. Create a list report named Cancelled Orders from the New Order form.
 
18. Add a filter to the Your Orders report to display only the cancelled orders.

See how it works                

Points to Note  

  • Instead of a stateless form to get the necessary details, we can open the New Order record and disable or hide the other fields, as well. We can create a workflow and during the edit of a record, we can disable or hide all the other fields except Cancellation section like this:
 
And add the below code in Deluge editor:
  1. disable Contact_Email;
  2. disable Order_Date;
  3. disable Delivery_Date;
  4. disable Total;
  5. disable Taxes;
  6. disable Net_Total;
  7. disable Order_Status;

  8. //Hide the subform
  9. hide Products;

  10. //Show the cancellation section
  11. show Cancellation; 
              





    Zoho CRM Training Programs

    Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

    Zoho CRM Training
      Redefine the way you work
      with Zoho Workplace

        Zoho DataPrep Personalized Demo

        If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

        Zoho CRM Training

          Create, share, and deliver

          beautiful slides from anywhere.

          Get Started Now


            Get started with Zoho Sign

            in a few quick steps!

            Download Help Guide





                        Still can't find what you're looking for?

                        Write to us:  support@zohoforms.com


                              




                            

                          Zoho Marketing Automation

                            Zoho Sheet Resources

                             




                                Zoho Forms Resources


                                  Secure your business
                                  communication with Zoho Mail


                                  Mail on the move with
                                  Zoho Mail mobile application

                                    Stay on top of your schedule
                                    at all times


                                    Carry your calendar with you
                                    Anytime, anywhere




                                          Zoho Sign Resources

                                            Sign, Paperless!

                                            Sign and send business documents on the go!

                                            Get Started Now


                                                Zoho SalesIQ Resources



                                                    Zoho TeamInbox Resources



                                                            Zoho DataPrep Resources



                                                              Zoho DataPrep Demo

                                                              Get a personalized demo or POC

                                                              REGISTER NOW


                                                                Design. Discuss. Deliver.

                                                                Create visually engaging stories with Zoho Show.

                                                                Get Started Now











                                                                                      • Related Articles

                                                                                      • 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 ...
                                                                                      • Disable Custom Actions after n times

                                                                                        Requirement  A custom action on a report has to be disabled after it is triggered three times. Use Case  We have an app to maintain customer invoices. After an invoice is created, the staff can email the invoice to the customer with the click of a ...
                                                                                      • Display custom action button for specific records

                                                                                        Requirement   The custom 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 ...
                                                                                      • Understand reports

                                                                                        A report is a compilation of data collected using a form in the created application. Zoho Creator incorporates reports as one of the components to complete the purpose of the application that you create. A report collates and presents information to ...
                                                                                      • Extract contents of a ZIP file and email the extracted files

                                                                                        Requirement   Use Deluge to extract a ZIP file and email the extracted files with the click of a button. Use Case   An HR management application contains three forms: Add Employee, Employee Payslips, and Download My Payslips. The Add Employee form ...
                                                                                      Wherever you are is as good as
                                                                                      your workplace

                                                                                        Resources

                                                                                        Videos

                                                                                        Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                        eBooks

                                                                                        Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                        Webinars

                                                                                        Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                        CRM Tips

                                                                                        Make the most of Zoho CRM with these useful tips.



                                                                                          Zoho Show Resources