For Zoho Services only:


I'm actually part of a bigger team at Ascent Business Solutions where we have support technicians and project consultants. Support is for smaller technical fixes but this can include developments, reports or integrations; depending on the size of the task. Projects are for more time-consuming developments such as revamps of the Zoho Suite of apps or on-site training. The advantage of a team is that if I am out-of-office for a day or so, there is always someone at Ascent Business Solutions who can deal with any queries/issues you may have.

Our support rates can be found and purchased at http://ascentbusiness.co.uk/zoho-support-2. A support bundle doesn't have an expiry date. So whether we can do what you want within the bundle and a year later need further support, if there are minutes left on the bundle then there is no additional charge.

Our project rates for bigger developments can be found at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices and will involve a dedicated project consultant along with developers who will hold your hand through the development process.

If you want help building a solution for one of the Zoho Apps in the Zoho Suite, contact us on 0121 293 8140 (UK) or by email at info@ascentbusiness.co.uk. You can also visit our website at http://ascentbusiness.co.uk.

I regularly build and specialize in 2-way API integrations for Xero, Shopify and eBay.

Zoho Creator: Two submit buttons on a non-stateless form with 2 different redirects

What?
This is an article to document how to have two submit buttons on a non-stateless form which both submit the form but one leaves the current record open while the other redirects to the reports view.

Why?
A client wanted a "Save" button on their form as well as a "Save & Close" button. The "Save" button would submit the form but keep the user on the record form. The "Save & Close" button would submit the form and then redirect the user to the report view of the records.

Zoho Creator: Two submit buttons on a non-stateless form: Result

Sounds simple but you can only set a form to redirect to one link and adding a HTML anchor link (<a href>) to the page won't help as you need to submit the form before redirecting the user.  A HTML <input type=submit> element to the page won't help either as you need to redirect the user to the specified report after submitting the form.

How?
Well as always, I'm going to cheat. My solution here was to simply repurpose a decision box field in Creator; then re-style it to look like a button; then add a workflow on click of this field.

  1. Set the form to reload the existing record when it is submitted (either on "Successful form submission", or on properties "On Successful Submission" > "Direct To", or my favorite, Deluge "openUrl()"). Standard as for any usual form without a redirect.
  2. Drag a decision box field on to the form; we are calling ours "Save & Close" with the field link name as "Save_and_Close" (the field link name is important for the next step: CSS styling):
    Zoho Creator: Two submit buttons on a non-stateless form: Decision Box field
  3. Apply the following styling (this will depend on the theme you are using):
    copyraw
    <style>
    		.zc-Save_and_Close-group .decision-box-field label{
    			display:none !important;
    		}
    		.zc-Save_and_Close-group label{
    			cursor:pointer;
    			outline:none;
    			text-align:center !important;
    			white-space:nowrap;
    			line-height:19px;
    			height:31px;
    			background-color: #6B47F4;
    			color:#fff !important;
    			font-weight: 400 !important;
    			font-size: 14px !important;
    			padding:7px !important;
    			box-shadow: 0 3px 8px 0 rgb(107 71 244 / 33%);
    			border-radius:5px;
    			width:100px;
    			max-width: 100px !important;
    			min-width: 100px !important;
    			float: right !important;
    			margin-right: 40px !important;			
    		}
    		.zc-Save_and_Close-group label:hover{
    			background-color: #613DEA;
    		}
    </style>
    1.  <style> 
    2.          .zc-Save_and_Close-group .decision-box-field label{ 
    3.              display:none !important; 
    4.          } 
    5.          .zc-Save_and_Close-group label{ 
    6.              cursor:pointer; 
    7.              outline:none; 
    8.              text-align:center !important; 
    9.              white-space:nowrap; 
    10.              line-height:19px
    11.              height:31px
    12.              background-color: #6B47F4; 
    13.              color:#fff !important; 
    14.              font-weight: 400 !important; 
    15.              font-size: 14px !important; 
    16.              padding:7px !important; 
    17.              box-shadow: 0 3px 8px 0 rgb(107 71 244 / 33%)
    18.              border-radius:5px
    19.              width:100px
    20.              max-width: 100px !important; 
    21.              min-width: 100px !important; 
    22.              float: right !important; 
    23.              margin-right: 40px !important; 
    24.          } 
    25.          .zc-Save_and_Close-group label:hover{ 
    26.              background-color: #613DEA; 
    27.          } 
    28.  </style> 
  4. In Workflow > Form workflows > Click on "New Workflow"
    1. Choose your form
    2. Run when a record is "Created or Edited"
    3. When to trigger workflow is "User input of a field"
    4. Choose Field "Save & Close"
    5. Name the workflow "OnSubmit_SaveClose"
      Zoho Creator: Two submit buttons on a non-stateless form: Workflow
    6. Add your deluge code that should:
      • Validate the fields (checks mandatory fields have been entered) for example:
        copyraw
        //
        // check mandatory fields have been entered
        l_Errors = List();
        if(isnull(input.Record_Name))
        {
        	l_Errors.add("- Record Name");
        }
        if(l_Errors.size() > 0)
        {
        	alert "Please enter the following required fields:\n" + l_Errors.toString("\n");
        }
        else
        {
        	// ... code to submit form/save to record here
        }
        1.  // 
        2.  // check mandatory fields have been entered 
        3.  l_Errors = List()
        4.  if(isnull(input.Record_Name)) 
        5.  { 
        6.      l_Errors.add("- Record Name")
        7.  } 
        8.  if(l_Errors.size() > 0) 
        9.  { 
        10.      alert "Please enter the following required fields:\n" + l_Errors.toString("\n")
        11.  } 
        12.  else 
        13.  { 
        14.      // ... code to submit form/save to record here 
        15.  } 
      • Then save the data by adding the record or updating the existing record
        copyraw
        if(!isnull(input.ID))
        {
        	// ... code to update existing record
        	r_Details = myForm[ID == input.ID];
        	r_Details.Account = input.Account.toLong();
        }
        else
        {
        	// ... code to create new record
        	r_NewRecord = insert into <formname>
        	[
        		<fieldname1> = <expression>
        		<fieldname2> = <expression>
        		<fieldname3> = <expression>
        	];
        }
        1.  if(!isnull(input.ID)) 
        2.  { 
        3.      // ... code to update existing record 
        4.      r_Details = myForm[ID == input.ID]
        5.      r_Details.Account = input.Account.toLong()
        6.  } 
        7.  else 
        8.  { 
        9.      // ... code to create new record 
        10.      r_NewRecord = insert into <formname> 
        11.      [ 
        12.          <fieldname1> = <expression> 
        13.          <fieldname2> = <expression> 
        14.          <fieldname3> = <expression> 
        15.      ]
        16.  } 
  5. Done:
    Zoho Creator: Two submit buttons on a non-stateless form: Result

Additional
  • Remember that an integration field on the interface is returned as a string and needs to be converted to a number to be assigned, eg:
    copyraw
    r_Details = myForm[ID == 1234567980123456789];
    r_Details.Account = input.Account.toLong();
    1.  r_Details = myForm[ID == 1234567980123456789]
    2.  r_Details.Account = input.Account.toLong()
Category: Zoho :: Article: 754

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Joes Word Cloud

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.