Page tree
Skip to end of metadata
Go to start of metadata

SmartForms can use the data from your website's environment, including:

User and Page Data is loaded when a form is started. It remains unchanged and cannot be modified during an entire life of a form.

This data is stored as named parameters that can be used to calculate field values and are usually accessible as components in Visual Designer.

User Details

The following table lists user details that are available for use in all website environments:

Parameter NameDescriptionJavaScript Code to Access Parameter Value
portal.user.idID of user, blank if user is not logged in
var userId = $portal[portal.user.id];
portal.user.first-nameFirst name of user, blank if user is not logged in
var firstName = $portal[portal.user.first-name];
portal.user.last-nameLast name of user, blank if user is not logged in
var lastName = $portal[portal.user.last-name];
portal.user.emailThe email address of user, blank if user is not logged in
var email = $portal[portal.user.email];
portal.user.rolesA comma-separated list of user roles
var rolesArray = $portal[portal.user.roles].split(",");
portal.user.logged-in'true' if user is logged in, 'false' if user is anonymous
var isLoggedIn = $portal[portal.user.logged-in];

The following tables list additional user details that are specific to website environment:

User Details in Liferay Portal Environment

Parameter NameDescriptionJavaScript Code to Access Parameter Value
liferay.user.screennameScreen name of user, blank if user is not logged in
var screenName= $portal[liferay.user.screenname];
liferay.user.group-rolesA comma-separated list of roles that user has for a group where the Form was deployed
var rolesArray = $portal[liferay.user.group-roles].split(",");
liferay.user.custom-field.FIELD-NAMEValue of user custom field that has FIELD-NAME name, blank if custom field is not defined or user is not logged in
var customValue = $portal[liferay.user.custom-field.FIELD-NAME];

Top of the page

Page Details

The following table lists page details that are available for use in all website environments:

Parameter NameDescriptionJavaScript Code to Access Parameter Value
portal.urlURL of a website where the SmartForm is deployed, e.g. https://www.mysite.com
var siteUrl= $portal[portal.url];
portal.page.urlURL of page of a website where the Form was started from, e.g. /web/users/annual-leave
var pageURL = $portal[portal.page.url];

The following tables list additional page details that are specific to website environment:

Page Details in Liferay Portal Environment

Parameter NameDescriptionJavaScript Code to Access Parameter Value
liferay.portal.nameName of a portal instance, e.g. 'HR Portal', fetched using company.getName() method
var portalName = $portal[liferay.portal.name];
liferay.company.idID of a portal instance, e.g. 31654, fetched using company.getCompanyId() method
var companyId= $portal[liferay.company.id];
liferay.hostnameA virtual host name of a portal instance, fetched using company.getVirtualHost() method
var portalName = $portal[liferay.hostname];
liferay.group.nameName of a scope group where the Form has been started from, fetched using group.getDescriptiveName() method
var groupName = $portal[liferay.group.name]
liferay.group.idAn ID of a scope group, fetched using PortalUtil.getScopeGroupId(...) method
var groupId= $portal[liferay.group.id];
liferay.portal.page.nameName of a page where the Form has been started from
var pageName = $portal[liferay.portal.page.name]
liferay.portal.page.idID of a page where the Form has been started from, fetched using layout.getPlid() method
var pageName = $portal[liferay.portal.page.id]
liferay.page.custom-field.FIELD-NAMEValue of page custom field that has FIELD-NAME name, blank if custom field is not defined
var customValue = $portal[liferay.page.custom-field.FIELD-NAME];

Top of the page

HTTP Session Attributes

In order for HTTP session attributes to be accessible in SmartForms the following rules have to be met:

  1. Session attribute name must start with the SMARTFORM_ prefix, case-insensitive;
  2. Session attribute value cannot be longer than 250 characters

Access to session attribute values is available via JavaScript calculations using $session[session-attr-name], e.g:

// If the session attribute name is 'SMARTFORMS_name1', it could be accessed using:
var attrValue = $session[name1];

Population of HTTP session attributes is outside of this reference material scope. This would largely depend on the platform where SmartForms is deployed.

Note for Liferay Portal developers:
/* 
   In Liferay Portal environment:
   to ensure that session attributes are passed to a Form, use session of an Original Servlet Request.
   See an example code below where PortalUtil class is used for sending custom data to SmartForms:
*/

String attributeName = "SMARTFORMS_attr1"; // make sure that attribute name starts with 'SMARTFORMS_'
                                           // In a Form, the following javascript call can be used 
                                           // to extract the value:
                                           // var attrValue = $session[attr1];

String attributeValue = "Value of attr 1"; // set the value which is not longer than 250 bytes

PortalUtil.getOriginalServletRequest(
  PortalUtil.getHttpServletRequest(renderRequest)).getSession().setAttribute(
    attributeName, attributeValue);

Top of the page

HTTP Request Parameters

HTTP request parameters are automatically loaded into SmartForms if the parameter value is not longer than 250 characters.

Access to request parameter value is available via JavaScript calculation using $request[request-param-name], e.g. if the Form has been started on the website page which has been accessed using the following URL:

https://yoursitename.com.au/your-page-name?param1=12345&param2=HQ35

parameter values can be accessed using the following code:

var par1 = $request[param1];
var par2 = $request[param2];

Top of the page

Related Links:

Default Value Settings

Runtime Value Calculation

  • No labels