What is an Expression?

An expression can consists of arithmetic expression, property expression, query expression and logical expressions. E.g. 12 + 3 * 4 / 5 = 14, or #{principle} * #{rate} * 100 / #{time} where principle, rate and time are the identifiers, or #{Person.city} where person is the identifier which points to data source object of Person and city is the property of person.

When do I use it?

You can use expressions to build Conditions and formulae.

Where an expression can be used?

In the following scenarios expression can be used.

Using expressions in formula attribute for different Item Types.
  1. Text Field
  2. Check Box
  3. Multi Field
  4. Number Field
  • If you want to assign a expression to a particular field in the page, you need to go to Customize Page.
  • Then select a field, Where you want to put an expression.

Select a field in left panel.png

  • Enter an expression in the formula attribute.

Enter data for formula.png

Using expressions, while configuring Email Actions

How to create Email Actions

Using expressions in Style Class attribute for Grid column

Apply Styles for Grid Column

What are the different functions available to be used in an expression?

Here is the list of functions you can use in expressions. Note: fuction names are not case sensitive i.e. SetReadOnly() is same as setreadonly()

Common Functions
Function NameSyntaxWhat it does?
IfNull ifNull(param1,param2) If param1 is null it returns the param2
Decode Decode(value,1,'one',2,'two','othervalue')

you can use decode function when you want to implement if - then - else conditions.

if the value == 1 then return "one"

else if the value == 2 then return "two"

else return "othervalue".

Format Format(date,format)
Evaluate

Evaluate('Paramater1','Parameter2','Comparision Operator')

You can use this function to compare two parameters.

First Parameter can be a output from UI Functions and other can be any other parameter.

Parameter values can be assigned directly or they can even be
assigned dynamically.

Eg:

Evaluate(tonumber(#{TimeSheetHeader.startdate},'dd'),15,'>') .

You can either specify GTE ,LTE ,LT,GT,EQ or ('>=','<=','<','>','==') For comparision operators.

tonumber

tonumber('Parameter')

tonumber('Date','dd' or 'MM' or 'yyyy')

Here Parameter is of type String or Date. If you want to convert date into number then you must specify the format.

It converts the given parameter value into number

Eg:

tonumber('16-07-2011','dd')

It returns the value as 16.

HasRole HasRole('rolecode') This is used to validate the role of the user. It returns boolean value TRUE/FALSE.
Eg:- HasRole('Manager')
This returns True, if the logged in user is a 'Manager'
Else it returns False.
You can also validate the multiple roles
Eg:- HasRole('Manager','Employee','Admin','Administration')
This function executes the 'OR' operation and if the user has any one of the role then it return TRUE else returns FALSE.
GetProfileValue GetProfileValue('profilecode') This is used to fetch the value set for a profile.
Eg:- (GetProfileValue('OJ_CUSTOMER')=='Y') 
It returns the value set for the profile code 'OJ_CUSTOMER'
UI Functions
Function NameSyntaxWhat it does
Ui

ui(

SetRequired('itemId1',true),

SetEnabled('itemId2',boolean)

)

A dummy function used to group a set of functions that needs to be executed in sequence. To be used only in UI Rules @ When True & When False.
SetEnabled SetEnabled('itemId',boolean) SetEnabled is primarily used for Buttons.
SetReadOnly SetReadOnly('itemId',boolean) to set read only attribute for an item.This is usually applied for form input fields like Text Fields,Number Fields etc,
SetVisible SetVisible('itemId',boolean) to set visible attribute for an item
SetInsertAllowed SetInsertAllowed('itemId',boolean) to override "Insert Allowed" property on particular item.This is usually applied for form input fields like Text Fields,Number Fields etc,
SetUpdateAllowed SetUpdateAllowed('itemId',boolean) to override "Update Allowed" property on particular item .This is usually applied for form input fields like Text Fields,Number Fields etc,
GetModelValue GetModelValue('modelName','attributeName') to get the attribute value from the model in the Store
SilentRefresh SilentRefresh('datasource') to refresh the datasource in the Store
SetWindowTitle SetWindowTitle('My Window') to set the title to window
SetHeading SetHeading('itemId','Item title') to set the title to a particular item in the page.
SetModelValue SetModelValue('modelName','attributeName','value') to set the attribute value in the model in the Store.
SetValue SetValue('datasource.attributeName','value') to set the attribute value in the datasource
SetRequired SetRequired('itemId1','itemId2','itemId3',true)

to set multiple items as required fields.

Note this function only works for TextFiled items.

GetGridColumnsTotal

GetGridColumnsTotal('Griditemid','Attributeid',

'fieldlabel','fieldlabel')

To get the sum of column values in a grid and assign it to any particular field .

Eg:GetGridColumnsTotal('item3','item54','selfpaid','companypaid').

GoToLink GoToLink('urlString')

to redirect or open a new window.

Note If you want to traverse the pages in the applications you need to give prefix '$p$pagecode'.For new window you can mention http url directly.

Refresh Refresh('datasource')
InsertRow InsertRow('datasource','model') to insert updated record in datasource into model
DoQuery DoQuery('datasource','model') to query a datasource from the store.
InitModel InitModel('modelName','datasource') to insert a datasource into Registry.
ShowError ShowError('Title','Error message') to show error message
GoToTarget
ShowStatus ShowStatus('Status message') to show the status message
GetResultValue GetResultValue('modelName','attributeName')
ShowInfo ShowInfo('This is info messagebox') to popup a messagebox with some information.
ShowAlert ShowAlert('title','Please enter proper values') to popup a messagebox with alert messages.
IsChanged IsChanged('datasource') to check datasource whether it has changed or not.
ConfirmYesNoCancel Confirmokcancel('Enter confirm message',Callback(showstatus('Cancel Selected'),showstatus('Selected'))) to show the ok, cancel popup to the user and perform callback functions based on the action performed.
ConfirmOkCancel Confirmokcancel('Enter confirm message',Callback(showstatus('Cancel Selected'),showstatus('Selected'))) to show the ok, cancel popup to the user and perform callback functions based on the action performed.
Commit
ClearDataSource ClearDataSource('datasource') to clear the datasource from the store.
InvokeQueryService InvokeQueryService('modelname',CallBack())
ResetFormPanel ResetFormPanel('FormPanelItemId','modelname')
InvokeService InitModel('as', 'AddressStyles'),
SetModelValue('as', 'territorycode', #{Addresses.country}),
InvokeService('as',
callback( null , ResetFormPanel('AddressEditForm', 'as'))
)

to call PL/SQL API in async mode.
HideColumn

HideColumn('gridItemId','columnItemId1','columnItemId2

.....,boolean)

to set one or more column visible true and false dynamically.Note this function only works for grid.
SetColumnHeader SetColumnHeader('gridItemId','columnItemId',String) to change the column heading dynamically.Note this function only works for grid.
SetRecordStatus SetRecordStatus('datasource','status') to change the current record in the Store. where status can be 'New','Insert','Query','Update'
InvokeValidateService InvokeValidateService ('datasource',CallBack())
evaluateSelectSQL evaluateSelectSQL('sqlquery', boolean) to query the tables in database from pre-query or postquery. When true it queries the APPS schema and when false it queries the XXRA schema
executequery executequery(sql,params,boolean) When true it queries the APPS Schema and when false it queries the XXRA Schema

Date Functions

Function NameSyntaxWhat it does?
AddDate AddDate(toDate, int, units)

to add number of months, days or years to the date. where units can be 'year','month','day','hour','minute','second','millisecond'

e.g.

AddDate(#{session.sysdate}, 3, 'year');

AddDate(#{session.sysdate}, -1, 'hour');

CurrDate Currdate() returns client's (browser) date & time.
DateDiff DateDiff(startDate, endDate, units[optional]) to get the difference between two dates, where units can be one of the following value 'year','month','day','hour','minute','second','millisecond'
StartingDayOfWeek StartingDayOfWeek()
IsSameDate IsSameDate(date, date) to check the equality of two dates
DaysBetween DaysBetween(startDate, endDate) to get days between to dates.
WeekDaysBetween WeekDaysBetween(startDate, endDate) to get week days between two dates.
TrimDate TrimDate(currdate()) removes the hours, minutes & seconds from a given date.
String Functions
Function Name
CharAt
Concat
EndsWith
EqualsIgnoreCase
IndexOf
StartsWith
SubString
ToLowerCase
Trim
ToUpperCase
Math Functions
Function NameSyntaxWhat it does?
Max Max(#{firstNumber}, #{secondNumber})

Math.max

Min Min(#{firstNumber}, #{secondNumber})

Math.min

Abs Abs(#{firstNumber})

Math.abs

Round Round(#{firstNumber})

Math.round

Some Examples

Common Function Expressions
  1. IfNull(#{datasource.propertyName},'somevalue')  if datasource.propertyName is null, then it returns 'somevalue'
  2. Decode(null,null,'two') which returns 'two' #TODO need to add explanation
  3. Format(date,format) converts the date into given format.


Here are some of the Date Formats

LettersDate or Time ComponentPresentationExamples
G Era Designator Text AD
Y Year Year 1996,96
M Month in year Month July,Jul,07
w Week in year Number 27
W Week in month Number 4
D Day in year Number 189
d Day in month Number 10
F Day of a week in month Number 2
E Day in week Text Tuesday.Tue
a Am/pm marker Text PM
H Hour in a day(0-23) Number 0
k Hour in a day(1-24) Number 24
K Hour in am/pm(0-11) Number 0
h Hour in am/pm(1-12) Number 10
m Minute in hour Number 30
s Second in minute Number 55
S Millisecond Number 978
z Time zone General time zone Pacific Standard Time, PST,GMT-08:00
Z Time zone RFC 822 time zone -0800
  1. Evaluate('Parameter1','Parameter2','Comparision operator') Compares the relation between two parameters like GreaterthanorEqual('GTE' or '>='),LessthanorEqual('LTE' or '<='),Greaterthan('GT' or '>'),
    Lessthan('LT' or '<'),Equals('EQ' or '=='). It returns boolean.
  2.  tonumber('Parameter') It returns the parameter's value as number. tonumber('16') returns 16, tonumber('16-07-2011','dd') returns value as 16.
  3. HasRole('Manager','Employee','Admin','Administration') This function executes 'OR' operation and if the user has any one of the role then it return TRUE else returns FALSE.
String Function Expressions
  1. CharAt('David',2) returns v 
  2. Concat('First','Last') returns "FirstLast"
  3. EndsWith('First','st') returns true
  4. EqualsIgnoreCase('First','fiRST') returns true
  5. IndexOf('First','s') returns 3
  6. StartsWith('First','F') returns true
  7. SubString('Some String',3) returns "e String"
  8. ToLowerCase('SoMeStRING') returns "somestring"
  9. Trim(' SoMeStRING ') returns "SoMeStRING"
  10. ToUpperCase('soMeString') returns "SOMESTRING" 
UI Expressions
  1. SetVisible('tsmMonth2',false)  where tsmMonth2 is ItemId.  
  2. ShowAlert('Message title','This is sample text')
  3. ShowError('Error Message title','This is error test')
  4. SetHeading('tsmTimeSheetMasterGrid','This is Heading') where tsmTimeSheetMasterGrid is ItemId
  5. SetWindowTitle('This is Window Title')
  6. SetReadOnly('tsmEmployeeId',true) where 'tsmEmployeeId' is ItemId
  7. ShowStatus('This is show status')
  8. SetInsertAllowed('tsmTimeSheetMasterGrid',false)
  9. HideColumn('tsmTimeSheetMasterGrid','tcClientId_10256','tcClientName_10256',true) where 'tsmTimeSheetMasterGrid' is the grid ItemId and 'tcClientId_10256,'tcClientName_10256' are column ItemId.
  1. SetColumnHeader('tsmTimeSheetMasterGrid','tcClientName_10256','This is Heading')
  2. GetGridColumnsTotal('item3','item54','selfpaid','companypaid') This will calculate the sum of the selfpaid and companypaid and assigns the value to a field with itemid 'item54'
Arithmetic Expressions
  1. -10 / 2
  2. 10 + (10 / 2) - 10 * 2 + 10 % 6
  3. 20 - (10/-2 + (-5 * -2)) / (15 * (-5/5) ) 
Logical Expressions
  1. true && !true
  2. (false && !true) && !(false && !true)
  3. (false && !true) || (!(false && !true) || !false)
  4. true == true
  5. true != false
Math Function Expressions
  1. min(3, 9) + 1 = 4
  2. max(3, 9) + 1 = 10
  3. abs(-4.5) + 1 = 5.5
  4. round(2.43) + 1 = 3.0 
Property Expressions
  1. #{datasource.propertyName}
  2. #{person.name} returns value of the name property in person object. 
Ternary Expressions
  1. 1/2 == 1/2 ? 10 : 3 returns 10
  2. 7/3 >= 7 ? 'It is seven' : 'Not seven' returns Not seven
  3. 1 == 2 ? 'blah' : null returns null 
Null check Expressions
  1. 1.0 != null returns true
  2. 'checkMe' != null returns true
  3. null + 5.0 returns null
  4. null * 4 returns null
#{OMOrderHeader.orderholdflag}=='Y'?'Holds: <span style="color: red; font-weight: bold;">[On Hold]</span>':'Holds'
'Open Orders on Hold - ' + format(#{OpenOrderHolds:holdsBar.Ext Amount.sum},'m')

Location

101 California Street, Suite 2710
San Francisco, CA 94111


440 N. Wolfe Rd.
Sunnyvale, CA 94085


Office 11, 5th Floor, Building 9,
Mindspace IT Park
Hyderabad 500081

p: +1 (844) AT CloudIO (844-282-5683)
f: +1 (650) 300-5247 | e: sales@cloudio.io
© 2009, 2017 CloudIO Inc. | Terms of Use | Privacy Policy