Expression Tag in QPR UI

From Mea Wiki
Revision as of 15:54, 23 January 2018 by Ollvihe (talk | contribs)
Jump to navigation Jump to search

Expression tag is used to calculate an expression (formula) and show its result in place of the tag. It's possible to use context variables in expressions using square brackets, for example [VariableName]. If the expression returns a date or numeric type of data, the data is converted into string using the browsers current locale settings. The expression is calculated again if the context variables used by the expression changes.

QPR uses Syncfusion Calculate expression language. See all available functions here: https://help.syncfusion.com/js/calculate/supported-formulas/supported-formulas

Parameters:

  • value: Expression string to calculate.
  • escape: Determines which escaping or encoding is applied to the calculation result so that the value is compatible with its context, e.g. inside string literal quotation marks. Available escapings are the same as in the Variable tag.

Note that the expression language works in a way that it returns 0 for empty strings, and also string literals are returned enclosed by quotation marks. For example, <#expression value="\"abc\""> returns "abc" which might not be consistent (the result should not contain quotation marks). To workaround the issue, you can use concatenate function, for example: <#expression value="concatenate(\"abc\", \"\")"> (strings returned by functions don't have this issue).

Examples:

  • <#expression value="SQRT([variable1] * [variable1] + [variable2] * [variable2])">
  • <#expression value="LEFT(\"limit this string to 17 characters\", 17)">
  • <#expression value="UPPER(\"show me in upper case\")">
  • <#expression value="YEAR(NOW())">
  • <#expression value="EDATE(NOW(), 12)">

Cell function

The cell function is used to get a single cell value from a dataset. It can be used for example when there is a query that only returns a single value (dataset with only one column and one row).

Parameters:

  1. name: Identifier of the referenced dataset. This parameter is mandatory. Error is caused if the referenced dataset identifier is not found.
  2. columnName/columnIndex: Referenced column name or index in the dataset. This parameter is optional, and if omitted, the first column of the dataset is referenced. If the provided parameter is string, it means column name; if it's numerical, it means column index.
  3. rowIndex: Referenced row number in the dataset (starting from 1). This parameter is optional and if omitted, the first row is used.
  4. default value: The optional default value is returned if the referenced columnName, columnIndex or rowIndex is not found. If no default value is defined in those cases, an error is caused.


Examples:

  • <#expression value="cell(\"myScorecard\")">
  • <#expression value="cell(\"myScorecard\", \"symbol\", 3)">
  • <#expression value="cell(\"myScorecard\", 2, 3)">
  • <#expression value="cell(\"myScorecard\", 1, 1, \"Default value\")">

Info function

Info function is used to access different kind of user, session and context related information, that is useful for building views. The function has one string valued parameter with following options:

  • baseUrl: Beginning part of the QPR UI url (until the "#" sign). The url is fetched using JavaScript command window.location.href. Example: https://demo.qpr.com/ui/.
  • paSessionId: QPR ProcessAnalyzer session id. The result is empty if there is no active session for QPR ProcessAnalyzer.
  • paWsUrl: QPR ProcessAnalyzer web service url. The result is empty if QPR ProcessAnalyzer web service url has not been configured. Example: https://demo.qpr.com/QPRPA/MainService.svc/webHttp/.
  • sessionContext: Current session context variables encoded to a url form. Example: sys:dashboard=1234&var1=value1&val2=value2.
  • sessionId: QPR UI session id.
  • qprSuiteSessionId: QPR Suite session id. The result is empty if there is no active session for QPR Suite.
  • qprSuiteWsUrl: QPR Suite web service url. The result is empty if QPR Suite web service url has not been configured. Example: https://demo.qpr.com/QPR2017-1/Portal/QPR.Isapi.dll/wsforward/MainService.svc/webHttp/.
  • uiLanguage: Language code of the currently active UI language. Available UI language codes: en_US (English), fi_FI (Finnish), ar (Arabic).
  • userFullName: Full name of the currently logged in user. If both QPR Suite and QPR ProcessAnalyzer are in use, the non empty full name is used. If both are not empty, full name stored in QPR Suite is used.
  • userGroups: Groups of the the currently logged in user as a JSON array (sorted alphabetically). If both QPR Suite and QPR ProcessAnalyzer are in use, the list contains groups in both of them. Example: ["group1", "group2", "group3"].
  • userId: Id of the currently logged in user in QPR UI. Note that QPR Suite and QPR ProcessAnalyzer user id's are different than QPR UI user id.
  • userLoginName: User login name of the currently logged in user.
  • version: QPR UI release version number. Example: 2017.6.1.3402.

To use a context variable as an argument for the info function, use an info function name listed above as the context variable value and then provide the context variable name as an argument for the expression.

Examples:

  • QPR Suite session id: <#expression value="info(\"qprSuiteSessionId\")">
  • Url to the current view: <#expression value="Concatenate(info(\"baseUrl\") & \"#/dashboard?\" & info(\"sessionContext\"))">
  • Using a context variable named "mycontext" as the argument: <#expression value="info([mycontext])">

Concatenate function needs to be used to avoid adding unnesessary quotation marks.