Commonly Used Expressions in Miracle Studio

To simplify using Expressions while creating mobile forms, here are a few sample expressions.

Keep in mind the following values
  • identifier1 is a TextBox
  • identifier2 is a TextBox
  • identifier3 is a SegmentedControl

 

Binding Expressions

This expression is to be used in the Bindings tab when “Value” is selected in the attribute property. Using it shows or sets the value of controls like a Segmented control in other controls.

Expression

Controls["identifier3"].Value

This expression is to be used in the Bindings tab when “Value” is selected in the attribute property. Using it shows or sets the value of controls like a Segmented control in other controls.

Expression

Controls["identifier1"].Text

Arithmetic Expressions

You can use these expression to carry out basic arithmetic operations on the data in controls. 

Expressions

  • Addition: ToNumber(Controls["identifier1"].Text) + ToNumber(Controls["identifier2"].Text)
  • Subtration: ToNumber(Controls["identifier1"].Text) - ToNumber(Controls["identifier2"].Text)
  • Multiplication: ToNumber(Controls["identifier1"].Text) * ToNumber(Controls["identifier3"].SelectedValue)
  • Division: ToNumber(Controls["identifier1"].Text) / ToNumber(Controls["identifier3"].SelectedValue)

The following expression can be used to calculate the percentage of two TextBox controls and show them in another control. 

Expressions

(ToNumber(Controls["identifier1"].Text))/(ToNumber(Controls["identifier2"].Text))*100

Visibility Expression

You can use this expression to control the visibility of a control.

Expression

Controls["identifier3"].SelectedValue = "Other"

Email Field Expression

You can use this expression in To, BC. and CC fields when emailing form data in PDF form.

Expression

ControlsData[identifier1].controlValue[0]

Concatenation Expression

You can use the following expression to concatenate two control values with spaces in between.

Expression

Controls["identifier1"].Text + " " + Controls["identifier2"].Text + " " + Controls["identifier3"].SelectedValue

Current Time Display Expression

This expression allows you to show the device’s current time in the Date Picker, Date/Time Picker, and Time Picker controls.

Expression

Now().TimeOfDay

Notifications Expressions

This expression allows you to display notifications to users with specific roles.

Expression

Login.Roles.Find(Name = "notificationusers") ! null

This expression allows you to display notifications to users with specific user IDs.

Expression

Login.UserID="notificationusers"

Multi-Option Display Expression

The following expression is used in the DataSource property of a Picker or Auto Complete control to display the contents of a column in an entity.

Expression

Entity["EntityName"].GroupBy(["ColumnName"])

Filter Picker Expression

The following expression is entered in the DataSource property of a Picker control. It is used to populate a Picker control based on the value selected in another Picker control. 

Expression

Entity["locations"].FindAll(["Site"] = Controls["Site"].SelectedValue).GroupBy(["Location"])

Text Length Expression

The following expression sets the text length in a TextBox Control.  

Expression

Controls["identifier1"].Text.Substring(0, 50)