Difference between revisions of "Expression Tag in QPR UI"

From Mea Wiki
Jump to navigation Jump to search
 
(25 intermediate revisions by 2 users not shown)
Line 1: Line 1:
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.
+
Expression tag is used to calculate an expression (formula) and show its result in place of the tag. Context variables can be used in the expressions with square bracket syntax, 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 recalculated 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
+
QPR UI uses Syncfusion expression language. See all available functions: https://help.syncfusion.com/js/calculate/supported-formulas/supported-formulas.
  
 
Parameters:
 
Parameters:
* '''value''': Expression string to calculate.
+
* '''value''': Expression to evaluate.
* '''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 in QPR UI|Variable tag]].
+
* '''escape''': Escaping/encoding applied to the result to make the value compatible with its placement context, e.g. inside string literal quotation marks. Available escapings are the same as in the [[Variable Tag in QPR UI|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:
 
Examples:
* <#expression value="SQRT([variable1] * [variable1] + [variable2] * [variable2])">
+
<pre>
* <#expression value="LEFT(\"limit this string to 17 characters\", 17)">
+
<#expression value="SQRT([variable1] * [variable1] + [variable2] * [variable2])">
* <#expression value="UPPER(\"show me in upper case\")">
+
<#expression value="LEFT(\"limit this string to 17 characters\", 17)">
* <#expression value="YEAR(NOW())">
+
<#expression value="UPPER(\"show me in upper case\")">
* <#expression value="EDATE(NOW(), 12)">
+
<#expression value="YEAR(NOW())">
 +
<#expression value="EDATE(NOW(), 12)">
 +
</pre>
  
== Info function ==
+
Note that the expression language works in a way that it returns '''0''' for empty strings. Also string literals are returned enclosed by quotation marks. For example, '''<#expression value="\"abc\"">''' returns '''"abc"''' which might not be logical, as the result should not contain quotation marks. To workaround the issue, you can use the '''concatenate''' function, for example: '''<#expression value="concatenate(\"abc\", \"\")">'''. Strings returned by functions don't have this issue.
'''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: <nowiki>https://demo.qpr.com/ui/</nowiki>.
+
== Cell Function ==
* '''paSessionId''': QPR ProcessAnalyzer session id. The result is empty if there is no active session for QPR ProcessAnalyzer.
+
The '''cell''' function is used to get a single cell value from a dataset. The cell function can be used for example when there is a query that only returns a single value (dataset with only one column and one row), or to get a specific value from a query that returns multiple values.
* '''paWsUrl''': QPR ProcessAnalyzer web service url. The result is empty if QPR ProcessAnalyzer web service url has not been configured. Example:  <nowiki>https://demo.qpr.com/QPRPA/MainService.svc/webHttp/</nowiki>.
 
* '''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: <nowiki>https://demo.qpr.com/QPR2017-1/Portal/QPR.Isapi.dll/wsforward/MainService.svc/webHttp/</nowiki>.
 
* '''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.
+
Parameters:
 +
# '''Dataset identifier''': Mandatory identifier of the used dataset. Error is caused if the referenced dataset identifier is not found.
 +
# '''Column name or column index''': 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.
 +
# '''Row index''': Referenced row number in the dataset (starting from 1). This parameter is optional and if omitted, the first row is used.
 +
# '''Default value''': The optional default value is returned if the referenced column name, column index or row index does not exist. If no default value is defined in those cases, an error is caused.
  
 
Examples:
 
Examples:
* QPR Suite session id: <#expression value="info(\"qprSuiteSessionId\")">
+
<pre>
* Url to the current view: <#expression value="Concatenate(info(\"baseUrl\") & \"#/dashboard?\" & info(\"sessionContext\"))">  
+
<#expression value="cell(\"myScorecard\")">
* Using a context variable named "mycontext" as the argument: <#expression value="info([mycontext])">
+
<#expression value="cell(\"myScorecard\", \"symbol\", 3)">
 +
<#expression value="cell(\"myScorecard\", 2, 3)">
 +
<#expression value="cell(\"myScorecard\", 1, 1, \"Default value\")">
 +
</pre>
  
Concatenate function needs to be used to avoid adding unnesessary quotation marks.
+
== Info Function ==
 +
The '''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:
  
=Functions supported in upcoming releases=
+
{| class="wikitable"
Note: This chapter contains documentation for features that are not released yet, but will be available in near future!
+
!'''Name'''
 +
! '''Description'''
 +
|-
 +
||baseUrl
 +
||Beginning part of the QPR UI url (until the "#" sign). The url is fetched using JavaScript command window.location.href. Example: <nowiki>https://demo.qpr.com/ui/</nowiki>.
 +
|-
 +
||paSessionId
 +
||QPR ProcessAnalyzer session id. This is empty if there is no session for QPR ProcessAnalyzer. If [[Common QPR Authentication]] is used, QPR UI doesn't have the QPR ProcessAnalyzer session id, and in that case ''paSessionId'' contains the QPR UI session id.
 +
|-
 +
||paWsUrl
 +
||QPR ProcessAnalyzer web service url. The result is empty if QPR ProcessAnalyzer web service url has not been configured. Example:  <nowiki>https://demo.qpr.com/QPRPA/MainService.svc/webHttp/</nowiki>.
 +
|-
 +
||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. This is empty if there is no session for QPR Suite. If [[Common QPR Authentication]] is used, QPR UI doesn't have the QPR Suite session id, and in that case ''qprSuiteSessionId'' contains the QPR UI session id.
 +
|-
 +
||qprSuiteWsUrl
 +
||QPR Suite web service url. The result is empty if QPR Suite web service url has not been configured. Example: <nowiki>https://demo.qpr.com/QPR2017-1/Portal/QPR.Isapi.dll/wsforward/MainService.svc/webHttp/</nowiki>.
 +
|-
 +
||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 currently logged in user as a JSON array (groups are sorted alphabetically). If both QPR Suite and QPR ProcessAnalyzer are in use, the list contains groups in both of them. QPR ProcessAnalyzer groups where the user is as a [[Manage_Users_in_QPR_ProcessAnalyzer_Excel_Client#Assigning_User_to_User_Group|hidden member]], are not shown, because permissions restrict that user is not allowed to get that information. 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: 2018.1.0.1234.
 +
|-
 +
|}
  
== Cell function ==
+
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.
Cell function is used to retrieve a single cell value from a dataset. It can be used when there is a query to retreave a single value. In that case the returned dataset contains only one row and column.
 
  
Parameters:
+
===Examples===
# '''name''': Identifier of the referenced dataset. This parameter is mandatory. Error is caused if the referenced dataset identifier is not found.
+
QPR Suite session id:
# '''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.
+
<pre>
# '''rowIndex''': Referenced row number in the dataset (starting from 1). This parameter is optional and if omitted, the first row is used.
+
<#expression value="info(\"qprSuiteSessionId\")">
# '''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.
+
</pre>
 +
Url to the current view:
 +
<pre>
 +
<#expression value="Concatenate(info(\"baseUrl\") & \"#/dashboard?\" & info(\"sessionContext\"))">
 +
</pre>
 +
Using a context variable named "mycontext" as the argument:
 +
<pre><#expression value="info([mycontext])">
 +
</pre>
  
 
+
Concatenate function needs to be used to avoid adding unnesessary quotation marks.
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\")">
 
  
 
[[Category: QPR UI]]
 
[[Category: QPR UI]]

Latest revision as of 13:35, 7 February 2019

Expression tag is used to calculate an expression (formula) and show its result in place of the tag. Context variables can be used in the expressions with square bracket syntax, 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 recalculated if the context variables used by the expression changes.

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

Parameters:

  • value: Expression to evaluate.
  • escape: Escaping/encoding applied to the result to make the value compatible with its placement context, e.g. inside string literal quotation marks. Available escapings are the same as in the Variable tag.

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

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

Cell Function

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

Parameters:

  1. Dataset identifier: Mandatory identifier of the used dataset. Error is caused if the referenced dataset identifier is not found.
  2. Column name or column index: 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. Row index: 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 column name, column index or row index does not exist. 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

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

Name Description
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. This is empty if there is no session for QPR ProcessAnalyzer. If Common QPR Authentication is used, QPR UI doesn't have the QPR ProcessAnalyzer session id, and in that case paSessionId contains the QPR UI session id.
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. This is empty if there is no session for QPR Suite. If Common QPR Authentication is used, QPR UI doesn't have the QPR Suite session id, and in that case qprSuiteSessionId contains the QPR UI session id.
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 currently logged in user as a JSON array (groups are sorted alphabetically). If both QPR Suite and QPR ProcessAnalyzer are in use, the list contains groups in both of them. QPR ProcessAnalyzer groups where the user is as a hidden member, are not shown, because permissions restrict that user is not allowed to get that information. 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: 2018.1.0.1234.

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.