Util Functions¶
Application Utilities
Business Hours Utilities
Push Notification Utilities
Application Utilities
util\generateId( )¶
The util\generateId() function generates a unique ID value in the same format as a Mythradon row id.
Returns a string. i.e. '66125a72eff3382fa'
Example:
util\getApplicationParam( )¶
The util\getApplicationParam() function returns the value of an application parameter as a string.
Possible Parameters types are:
- ApplicationName
- ApplicationUrl
Example:
$appName = util\getApplicationParam('ApplicationName');
$appURL = util\getApplicationParam('ApplicationUrl');
Business Hours Utilities
util\businessHoursAddHours( )¶
The businessHoursAddHours() function is used to add Business Hours to an existing date/time value.
For example if you need to add 14 business hours to a date/time value that is on a Friday afternoon and your standard business hours do not include weekends, then the new date/time value would probably be sometime on the following Tuesday. This function will calculate that new date/time based on the Business Hours used in the calculation. This function can be used to add a number of Business Hours to the passed in date/time by simply using a positive or negative value in the hourToAdd parameter.
Returns a Datetime.
util\businessHoursAddHours(BUSINESS_HOUR_ID, START_DATE_TIME, HOURS): DATETIME
Parameters
| Parameter | Description |
|---|---|
| BUSINESS_HOUR_ID | Unique row id of a Business Hours record that you wish to use for calculating the time between the start and end dates |
| START_DATE_TIME | Initial date/time value that you wish to add to the Business Hours |
| HOURS | Number of Business Hours to add to the initialTime value |
Example:
// This assumes a Business hours record called 'Melbourne' exists
$busHourId = record\findOne('BusinessHourMyth', 'createdAt', 'desc', 'name=', 'Melbourne');
output\printLine($busHourId);
$now = datetime\now();
$hours = 10;
$due = util\businessHoursAddHours($busHourId, $now, $hours);
output\printLine( string\concatenate('Current Date/time: ', $now) );
output\printLine( string\concatenate('Due Date/time: ', $due) );
Note
All date/time values returned by a formula function will be in UTC/GMT timezone. When these datetime values are accessed through the API or displayed in the user interface, they are converted to match the timezone offset of the current user.
util\businessHoursCalcHours( )¶
The businessHoursCalcHours() function is used to calculate the number of Business Hours between one date/time value and a second date/time value.
Returns a float.
util\businessHoursCalcHours(BUSINESS_HOUR_ID, START_DATE_TIME, END_DATE_TIME): FLOAT
Parameters
| Parameter | Description |
|---|---|
| BUSINESS_HOUR_ID | Unique row id of a Business Hours record that you wish to use for calculating the time between the start and end dates. |
| START_DATE_TIME | Start Date/Time value. |
| END_DATE_TIME | End Date/Time value. |
Example:
$busHourId = record\findOne('BusinessHourMyth', 'createdAt', 'desc', 'name=', 'Melbourne');
output\printLine($busHourId);
$now = datetime\now();
$hours = number\round(250);
output\printLine( string\concatenate('Hours: ', $hours) );
$due = util\businessHoursAddHours($busHourId, $now, $hours);
output\printLine( string\concatenate('Current Date/time: ', $now) );
output\printLine( string\concatenate('Due Date/time: ', $due) );
$numOfBusHours = util\businessHoursCalcHours($busHourId, $now, $due);
output\printLine( string\concatenate('Number of Business Hours btw : ', $numOfBusHours) );
ifThenElse($numOfBusHours == $hours, output\printLine('Accurate Calculation'), output\printLine('Invalid Calculation'));
Note
All date/time values returned by a formula function will be in UTC/GMT timezone. When these datetime values are accessed through the API or displayed in the user interface, they are converted to match the timezone offset of the current user.
Push Notification Utilities
Mythradon supports the following three functions for sending Push Notifications:
- util\SendNotificationToUser - Sends a Push Notification to a specific User identified by their Id value (Unique row id of a User record)
- util\SendNotificationToTeam - Sends a Push Notification to all the members of a specific Team identified by the Team Id (Unique row id of a Team record)
- util\SendNotificationToTeamsOnRecord - Sends a Push Notification to all the members of all the Teams associated to entity id the formula is being used on
Note
The Send Notification functions support a set of Name/Value pair parameters known as 'OPTION_NAME'/'OPTION_VALUE'. The only parameter that is currently supported is 'url'. However, Mythradon intends to expand these functions in the future.
util\SendNotificationToUser( )¶
The SendNotificationToUser() function will send a Push Notification to a specific User.
util\SendNotificationToUser(USER_ID, TITLE, MESSAGE, OPTION_NAME1, OPTION_VAL1, OPTION_NAME.., OPTION_VAL..): NULL
Parameters
| Parameter | Description |
|---|---|
| USER_ID | Unique row id of a User record that you wish to send the Push Notification to. |
| TITLE | Title in the Push Notification message. |
| MESSAGE | Body of the Push Notification message. |
| OPTION_NAME | First name of the name/value pair parameters. Only value currently supported is 'url'. |
| OPTION_VAL | First value of the name/value pair parameters. Only value currently supported is a valid url that will be a link in the Push Notification. |
Example
util\SendNotificationToUser(id, 'Hello World', 'That/'s one small step for man, one giant leap for mankind.', 'url', 'https://airandspace.si.edu/stories/editorial/one-small-step-man-or-man');
Note
The Send Notification functions support a set of Name/Value pair parameters known as 'OPTION_NAME'/'OPTION_VALUE'. The only parameter that is currently supported is 'url'. However, Mythradon intends to expand these functions in the future.
util\SendNotificationToTeam( )¶
The SendNotificationToTeam() function will send a Push Notification to all the members of a specific Team identified by the Team Id (Unique row id of a Team record).
util\SendNotificationToTeam(TEAM_ID, TITLE, MESSAGE, OPTION_NAME1, OPTION_VAL1, OPTION_NAME.., OPTION_VAL..): NULL
Parameters
| Parameter | Description |
|---|---|
| TEAM_ID | Unique row id of a Team record that you wish to send the Push Notification to. |
| TITLE | Title in the Push Notification message. |
| MESSAGE | Body of the Push Notification message. |
| OPTION_NAME | First name of the name/value pair parameters. Only value currently supported is 'url'. |
| OPTION_VAL | First value of the name/value pair parameters. Only value currently supported is a valid url that will be a link in the Push Notification. |
Example
$url = string\concatenate(util\getApplicationParam('ApplicationUrl'), '/#Case/view/', id);
util\SendNotificationToTeam(teamsIds, 'Hello World', 'That/'s one small step for man, one giant leap for mankind.', 'url', 'https://airandspace.si.edu/stories/editorial/one-small-step-man-or-man');
util\SendNotificationToTeamsOnRecord( )¶
The SendNotificationToTeamsOnRecord() function will send a Push Notification to all the members of all the teams that are associated to a record.
Mythradon supports the ability to assign more than one teams to a record. Teams are used in conjunction with Roles to control visibility to records. Mythradon also allows for a User to be a memeber of many teams.
The sendNotificationToTeamsOnRecord() function allows you to send a Push Notification all all members of all teams. If a User is a member of more than one Team that is assigned to the record, they will only receive a single Push Notification message.
util\SendNotificationToTeamsOnRecord(ENTITY_ID, ENTITY_TYPE, TITLE, MESSAGE, OPTION_NAME1, OPTION_VAL1, OPTION_NAME.., OPTION_VAL..): NULL
Parameters
| Parameter | Description |
|---|---|
| ENTITY_ID | Unique row id of an Entity that you want to send a Push Notificication all the related Team members. |
| TITLE | Title in the Push Notification message. |
| MESSAGE | Body of the Push Notification message. |
| OPTION_NAME | First name of the name/value pair parameters. Only value currently supported is 'url'. |
| OPTION_VAL | First value of the name/value pair parameters. Only value currently supported is a valid url that will be a link in the Push Notification. |
Example
ifThen(
entity\isNew(),
$url = string\concatenate(util\getApplicationParam('ApplicationUrl'), '/#Case/view/', id);
util\SendNotificationToTeam('5f137834ed903a606', 'New Case Created', 'A new case has been created', 'url', $url);
);
See also¶
- Array Functions
- Datetime Functions
- Entity Functions
- Env Functions
- Ext Functions
- JSON Functions
- Language Functions
- Number Functions
- Object Functions
- Output Functions
- Password Functions
- Record Functions
- String Functions
- Mythradon Marketing
- Mythradon Sales
- Mythradon Service
- Mythradon System Administration
- Mythradon Tools