Saturday, February 28, 2015

Configuring webform URLs for Zoho CRM

Are you finding that your Zoho CRM web forms don't do anything? I've learned the hard way that it's generally because the form URL has not been set correctly. It seems like a throw-away setting, but it actually won't work unless you configure the form URL to be exactly where the form is on your website. Use this link to access the web form page, then click on the form name and finally click on "Next Step" to show this dialog.


Tuesday, February 17, 2015

Keeping your OnInput code DRY in Zoho Creator

DRY (don't repeat yourself) is one of the most important software development patterns to follow. If you copy and paste code, then if there's a bug, you'll have to go back and edit several code blocks which is likely to lead to even more bugs.

With Zoho Creator OnInput scripts, it can be challenging to apply DRY because you can't really use functions within an OnInput script. You can call a function at an app level, but this function won't be able to access any of the current form fields.

Here's an example I encountered recently when reviewing code from one of my devs.

As you'll read from the comments, this code isn't DRY. The same exact code block was used for several other OnInput functions. (The goal of this block is to update a subtotal field at the bottom of the form when the quantity or price is changed).

As mentioned, you can't use a custom function to achieve this, but you can put the code in one place. I typically create a new decision box field (e.g. Update_Sub_Totals) and put the code in there.

E.g. 
if (input.Update_Sub_Totals == true){
             //update sub-total code
             /*
             code block goes here
             */
             //reset the check box so it can be used
             input.Update_Sub_Totals = false;
          }
 


Monday, February 16, 2015

Configuring page breaks in Zoho Creator

I've had a helluva time trying to get page breaks to behave properly in Zoho Creator HTML pages when you export them as a PDF. Here's an example:
After trying absolutely everything, I finally realised that it just is not possible to properly configure page breaks in PDF mode.

However, there is a work-around. Use print mode and then use a print-to-pdf driver to save the output as a PDF.

Then all you have to do is add this CSS to the top of your page:

<style type="text/css">
   table { page-break-inside:auto }
   tr    { page-break-inside:avoid; page-break-after:auto }
   @media all {
.page-break  { display: none; }
   }
   @media print {
.page-break  { display: block; page-break-before: always; }
   }

</style>
This will prevent page breaks from occurring within tables. If you want to force a page break, you just have to add <div class="page-break"></div>.