We've Added New Expressions to the Device Magic Mobile App

Posted by on Sep 10, 2012 6:39:40 AM
Brett Long

We've added a bunch of new expressions to our forms designer. They're supported in the mobile applications for all of our platforms, but please make sure you're running the latest versions of the apps.

New Date Time Expressions:

These are available in the forms designer for working with dates and times.

Creating dates and times for use within expressions:

  • date(year, month, day)
  • time(hour, minute, second)
  • datetime(year, month, day, hour, minute, second)

Accessing parts of an existing date/time:

  • year(datetime)
  • month(datetime)
  • day(datetime)
  • hour(datetime)
  • minute(datetime)
  • second(datetime)

Manipulating date/times:

  • addYears(datetime, number_of_years_to_add)
  • addMonths(datetime, number_of_months_to_add)
  • addDays(datetime, number_of_days_to_add)
  • addHours(datetime, number_of_hours_to_add)
  • addMinutes(datetime, number_of_minutes_to_add)
  • addSeconds(datetime, number_of_seconds_to_add)

(Use negative values to subtract rather than add, and as always, the parameters can be constants in the expression or values from answers within the form.)

Other functions:

  • now() - returns the current datetime
  • 'datetimeA - dateTimeB' will return the number of seconds difference between A and B

Some quick examples:

  • 'addYears(MY_BIRTHDATE_QUESTION, 21) < NOW()' will be true if the person is 21 years or older, false otherwise
  • '(TIME_WORK_ENDED - TIME_WORK_STARTED) / 3600 * HOURLY_RATE' will calculate the cost of work done

If-Then-Else:

We've also added support for if-then-else expressions. They take the form:

  • if(SOME_CONDITION, RESULT_IF_TRUE, RESULT_IF_FALSE)

As an example, if you wanted to calculate the cost of some work done, and it depended on whether you'd originally give an fixed quote, or were going to charge for hours worked:

  • IF(PRICE_IS_FIXED_QUESTION, ORIGINAL_QUOTED_PRICE, HOURS_WORKED * HOURLY_RATE)

If you have issues getting these to work for you, or if we've missed anything, please let us know. Read through help docs or contact Support in the Device Magic Help Center.

Topics: Mobile Forms