Archive

Archive for November 15, 2020

Canvas Apps | Useful functions

November 15, 2020 Leave a comment

In this article, I am collating the useful formulas which are frequently used in Canvas Apps.

For all functions, I am going to use a Textbox control ‘txtInput’ as reference.

Match

Validates User inputs based on predefined or custom patterns. For example, you can confirm whether the user has entered a valid email address, SSN, etc…

Validate Email:
  • IsMatch(txtInput.Text,Email)
Validate SSN:
  • IsMatch( txtInput.Text, Digit & Digit & Digit & Hyphen & Digit & Digit & Hyphen & Digit & Digit & Digit & Digit )
Validate SSN using Regular Expression (RegEx)
  • IsMatch( txtInput.Text, “\d{3}-\d{2}-\d{4}” )
Check presence of string
  • IsMatch( txtInput.Text, “hello”, Contains & IgnoreCase)
    • Check if ‘hello’ exists in the Text input.

User

Get Current User Email
  • User().Email
Get Current User Fullname
  • User().FullName
Get Profile Image
  • User().Image
    • Add an Image control and set ‘Image’ property with User().Image.

Date functions

Today()
  • Returns the current date as a date/time value.
  • The time portion is always midnight (i.e., 12:00:00). 
Now()
  • Returns the current date and time as a date/time value
IsToday()
  • Checks whether a date/time value is between midnight today and midnight tomorrow. Returns a Boolean (true or false) value.
Weekday()
  • Weekday(Date)
    • Returns between 1-7 and Sunday is ‘1’.
DateDiff()
  • DateDiff(Date1.SelectedDate, Date2.SelectedDate, Days)
    • ‘Date1’ and ‘Date2’ are ‘Date Picker’ controls.

Miscellaneous

  • IsBlank(txtInput)
    • Checks for a blank value or an empty string.
  • Coalesce
    • Evaluates its arguments in order and returns the first value that isn’t blank or an empty string.
    • Use this function to replace a blank value or empty string with a different value but leave non-blank and non-empty string values unchanged
  • GUID
    • GUID() – Returns a new Guid.
      • Set( NewGUID, GUID() )
    • To generate 5 new GUIDs and set to Collection
      • ClearCollect( NewGUIDs, ForAll( Sequence(5), GUID() ) )

🙂

Categories: CRM