HTML and Script components

HTML and Script components allow you to add templates and formulas to a page. The HTML will be rendered when the user views a page. Script components can perform calculations and handle events using JavaScript. Adding business logic introduces where templates and formulas can be used in a Platform application.

HTML components

HTML components allow you to customize the way a page displays. You can use them on application or portal pages. You can add formatting with stylesheets and HTML code. The Template Helper makes it easy to add data elements, perform calculations, or call Platform APIs to perform functions. You can also use string tokens in HTML components. See Creating and using string tokens for information about custom string tokens. To add Javascript formulas to an HTML component, insert them in <script> elements.

As a simple example, suppose you want to provide a greeting to the current end user on an application page. You can simply add an HTML component to the page and use a token to retrieve the name. The following shows how to use the Template Helper to find the token for selecting the current user and filling in the first name:

Rollbase - HTML component example

With the user Adam Ministrator logged in, Platform renders this template as follows:

Rollbase - Customized greeting using token for current
                        user

Script components

Script components can perform calculations and handle events using JavaScript. You can also use string tokens One use of a script component is to customize page content when the page is loaded. For example, suppose you want to hide a field and its label when the page is loaded. The following script shows how to structure an event handler in a script component, in this case, an event handler for the rb.newui.util.customEvents.rbs_pageRender event, which occurs when a page is loaded using an AJAX request, the response to the request has been received and rendered.


<script>
            
   rb.newui.util.addEventListener(rb.newui.util.customEvents.rbs_pageRender,function(){ 
      console.log('page is rendered');
   rbf_showOrHideField("Checkbox",false); 
   });
</script>