Add a ZML Snippet to a Page | Zoho Creator Help

Understand ZML snippet

Snippets are stand-alone, re-usable code pieces that can add additional functionality. ZML or Zoho Markup Language is a simple markup language used to create pages in your Zoho Creator Appliction. Using ZML, you can build various elements of your page, create a display structure to arrange these elements on the page, add descriptive and logical properties to these elements, format the contents of these elements and more. Learn more

Adding a ZML snippet to your page

  1. Edit your app.
  2. Navigate to the Design tab and open the page builder.
  3. In the page builder, click Snippets on the left, then drag and drop the ZML Snippet on to the required position on your page. The ZML Snippet editor will appear.


  4. Add the required ZML code. Below image shows a reference code to add a panel in the ZML snippet.


  5. Click Save and close the editor.
  6. Access your live page and the respective snippet will be displayed.

Adding multiple arguments to a function in ZML snippets

ZML snippets also allow for the passing of multiple arguments in functions. Let's assume an application Resource Management for which we have a function along with a ZML snippet that allows us to pass an email address as page variables and send the mail on click of a button in the page. Here, ${frmAdrs} and ${toAdrs} are the two page variables.


The ZML snippet for the button.
  1. <%{
  2. %>
  3. <panel elementName="Panel">
      <pr width='fill' height='fill'>
        <pc padding='20px' bgColor='#FFFFFF' width='100%' hAlign='center' vAlign='middle'>
          <pr width='auto' height='auto'>
            <pc>
              <button marginLeft='0px' marginRight='0px' marginBottom='0px' marginTop='0px' action='ExecuteFunction' parameters='${frmAdrs},${toAdrs}' functionName='toSendMail' color='#FFFFFF' size='16px' text='Send Mail' type='flat' bgColor='#0072F4' cornerRadius='3px' /> </pc>
          </pr>
        </pc>
      </pr>
    </panel>
  4. <%
The function to pass the parameters.
  1. void toSendMail( string FrmAdrs, string ToAdrs )
    {
    sendmail
        [
        from: input.FrmAdrs
        to: input.ToAdrs
        subject: "Send mail task"
        message: "Message"
        ]
    }

Things to know

Let's say you have a form that contains a multi-line field. If you've entered your input in the multi-line field with line breaks, the same is displayed in your report. However, the line breaks will not appear if you use the same multi-line field as inside the <text> tag in a ZML snippet.
To ensure that line breaks appear when you enter paragraphs or a list of data that you intend to be vertical, you can use the below script to achieve the same.
  1. <%{
  2.     newLine = hexToText("0A");
  3.     html_lineBreak = "<br>";
  4.     encoded_lineBreak = html_lineBreak.replaceAll("<","&lt;").replaceAll(">","&gt;");
  5.     var = Form[ID != null].Multi_Line_Field;
  6.     new_text = var.replaceAll(newLine,encoded_lineBreak);
  7.     %>
  8. <panel> 
  9.     <pr hAlign='left'>
  10.         <pc>
  11.             <text renderAsHtml='true' value='<%=new_text%>'></text>
  12.         </pc>
  13.     </pr>
  14. </panel>
  15. <%
  16. }%>
Using this code, your input is reflected just as you have entered.

Input:
      

Output:

      




    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


            Zoho Sign now offers specialized one-on-one training for both administrators and developers.

            BOOK A SESSION





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

                        Write to us:  support@zohoforms.com

                                                                       
                            



                            






                              You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                  Manage your brands on social media

                                    Zoho Desk Resources

                                    • Desk Community Learning Series


                                    • Digest


                                    • Functions


                                    • Meetups


                                    • Kbase


                                    • Resources


                                    • Glossary


                                    • Desk Marketplace


                                    • MVP Corner


                                    • Word of the Day


                                      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 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

                                                                                                • Getting started with ZML

                                                                                                  Being new to ZML, it can be hard for any user to know where and how to start. It's easy to get stuck somewhere wasting a lot of your time and efforts (and of course, Money!). The aim of this guide is to show you ‘how’ to create your first panel ...
                                                                                                • Understand Pages

                                                                                                  As an application user, when you have collected enough data using multiple forms, you go for insights, using the Reports component. Now, the primary rationale of collecting such vast amounts of data and generating reports is to measure, monitor and ...
                                                                                                • Understand HTML snippets

                                                                                                  Snippets are stand-alone, re-usable code pieces that can add additional functionality. An HTML snippet is a small portion of source code in HTML. They can be used to build different elements (like a list view, different styled buttons, text display, ...
                                                                                                • Building an employee dashboard

                                                                                                  Requirement   Create an employee dashboard with buttons that will help the employees to check in and out, find the total number of logged-in hours and apply for leave. Use Case   An Employee Management application has a dashboard for their employees. ...
                                                                                                • Understand snippets

                                                                                                  Snippets are components that let you add short, custom codes to your page. Conventionally, snippets are stand-alone, re-usable code pieces that can add additional functionality. Types of snippets in a page: ZML snippet HTML snippet Embed For example, ...
                                                                                                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