Skip to content

Ext Functions

The Ext function group include a range of general extension functions that include sending of Emails, SMS messages, generating PDF documents and working with the Working Time calendars.


ext\account\findByEmailAddress( )

The ext\account\findByEmailAddressDomain() function searches for an account using an email address. If a full match is not found, it attempts to locate an account by the domain name of the email, excluding domains from free email providers. It returns the account ID if found, or null if no match is available.

ext\account\findByEmailAddress()
ext\account\findByEmailAddress(EMAIL_ADDRESS)

Examples

ext\account\findByEmailAddress() Example 1
// In this example there exists an Account record with the email address 'harry.jones@harrysbikehire.com.au'
// however we will search for just the domain.

$account = ext\account\findByEmailAddress('harrysbikehire.com.au');
output\printLine($account);  // Prints the id of the Account record. I.e. 64b4cf4e5f0ad1ec7
ext\account\findByEmailAddress() Example 1
// In this example there exists an Account record with the email address 'hello@123box.net'
// however we will search for just the domain '123box.net' which is listed as a Free Email Provider domain

$account = ext\account\findByEmailAddress('123box.net');
output\printLine($account);  // No record is found


ext\currency\convert( )

The ext\currency\convert() function converts a currency amount from one currency code (FROM_CODE) to another currency code (TO_CODE). If TO_CODE is omitted, then the system default currency is used. Returns an amount represented as string.

ext\currency\convert()
ext\currency\convert(AMOUNT, FROM_CODE, [TO_CODE])

Example:

ext\currency\convert() Example
$convertedValueString = ext\currency\convert(amount, amountCurrency);
$convertedValue = number\parseFloat($convertedValue);


ext\email\send( )

The ext\email\send() function dispatches an email based on the specified EMAIL_ID. It returns TRUE if the email is successfully sent, or FALSE if the sending fails.

If the from address is not specified in the email, the system's default email address is used. Moreover, if the from address matches the address of a group email account, the SMTP settings of that group email account are applied.

Note

The 'Is Shared' needs to be set on the Outbound Emails or the Group Email Account settings depending on the from address being used.

ext\email\send()
ext\email\send(EMAIL_ID)

Example:

ext\email\send() Example
$id = record\create(
    'Email',
    'from', 'from-address@test.com',
    'to', 'to-address@test.com',
    'subject', 'Test from formula',
    'body', 'Hi,\n\nThis is a test.',
    'isHtml', false,
    'status', 'Sending'
);

ext\email\send($id);


ext\email\applyTemplate( )

The ext\email\applyTemplate() function utilises an email template to update an existing email record. Optionally, a parent record can be specified.

ext\email\applyTemplate()
ext\email\applyTemplate(EMAIL_ID, EMAIL_TEMPLATE_ID, [PARENT_TYPE, PARENT_ID])

Example:

ext\email\applyTemplate()
$emailId = record\create(
    'Email',
    'to', 'to-address@test.com',
    'status', 'Draft',
    'parentId', entity\attribute('id'),
    'parentType', 'Case'
);

ext\email\applyTemplate($emailId, 'some-email-template-id');
ext\email\send($emailId);


ext\pdf\generate( )

The ext\pdf\generate() function creates a PDF file using the specified TEMPLATE_ID and returns the attachment ID. If the generation fails, it returns NULL. Optionally, a FILENAME can be specified.

ext\pdf\generate()
ext\pdf\generate(ENTITY_TYPE, ENTITY_ID, TEMPLATE_ID, [FILENAME])

Example:

ext\pdf\generate() Example
$attachmentId = ext\pdf\generate('Lead', entity\attribute('id'), 'pdf-template-id', 'test.pdf');

$emailId = record\create('Email',
    'subject', 'Test PDF',
    'body', 'PDF is attached',
    'to', entity\attribute('emailAddress'),
    'attachmentsIds', list($attachmentId)
);

ext\email\send($emailId);


ext\sms\send( )

The ext\sms\send() function dispatches an SMS based on the given SMS_ID. It returns TRUE if the SMS is successfully sent, and FALSE if the sending fails.

ext\sms\send()
ext\sms\send(SMS_ID): BOOLEAN

Example:

ext\sms\send()
$smsId = record\create(
    'Sms',
    'fromName', 'Mythradon',
    'to', '+1000111222',
    'body', 'This is a test from Mythradon.'
);

ext\sms\send($smsId);

Note

The fromName is optional. If it is not set in the SMS record, then the system SMS from number will be used.


ext\user\sendAccessInfo( )

The ext\user\sendAccessInfo() function sends the standard access information email to the specified User ID, suitable for both standard Users and Portal Users.

Depending on whether the recipient is a standard User or a Portal User, one of two email templates will be used:

  • Access Info - template for standard Users
  • Access Info for Portal - template for Portal Users

To utilise these email templates:

  • Navigate to Administration → Template Manager via the Menu Button.
  • Choose Access Info for standard Users or Access Info for Portals for Portal Users.
ext\user\sendAccessInfo()
ext\user\sendAccessInfo($userId)


ext\workingTime\addWorkingDays( )

The ext\workingTime\addWorkingDays() function leverages the Working Calendar feature to calculate a new date-time. It takes a DATE and a specified number of DAYS as inputs and adds the number of working days to the DATE provided. The computed date-time will be formatted to the start of the day (00:00) in the applicable time zone.

ext\workingTime\addWorkingDays()
ext\workingTime\addWorkingDays(DATE, DAYS, [ENTITY_TYPE, ENTITY_ID]): STRING|NULL

Example:

ext\workingTime\addWorkingDays() Example 1
$dueDate = ext\workingTime\addWorkingDays(datetime\now(), 10);

Note

Working Time Calendars are structured across three tiers:

  1. Default: This is the System Level Working Time Calendar.
  2. Team: Pertains to the Team Level Working Time Calendar.
  3. User: Relates to the User Level Working Time Calendar.

For operations that require specificity, optional parameters such as [ENTITY_TYPE] and [ENTITY_ID] can be utilised, designated as either 'User' or 'Team', followed by the corresponding ID of the user or team.

Example:

ext\workingTime\addWorkingDays() Example 2
$currentDate = datetime\today();
$currentDateTimStr = string\concatenate('Current Date/Time: ', $currentDate);
output\printLine($currentDateTimStr);

// This due date will be calculated using the Default System Working Time Calendar
$dueDate = ext\workingTime\addWorkingDays($currentDate, 10);
$dueDateTimStr = string\concatenate('Due Date: ', $dueDate);
output\printLine($dueDateTimStr);

// This due date will be calculated using a specific Team level Working Time Calendar
$entityType = 'Team';
$teamId = '5f137834ed903a606';

$dueDate = ext\workingTime\addWorkingDays($currentDate, 10, $entityType, $teamId);
$dueDateTimStr = string\concatenate('Due Date: ', $dueDate);
output\printLine($dueDateTimStr);

// This due date will be calculated using a specific User level Working Time Calendar
$entityType = 'User';
$userId = entity\attribute('Id');

$dueDate = ext\workingTime\addWorkingDays($currentDate, 10, $entityType, $userId);
$dueDateTimStr = string\concatenate('Due Date: ', $dueDate);
output\printLine($dueDateTimStr);

Note

If the formula fails to create a new datetime value, check that you have a default Working Time Calendar defined in Administration → Settings.

Click here for more information on Working Time Calendars


ext\workingTime\findClosestWorkingTime( )

The ext\workingTime\findClosestWorkingTime() function identifies the start of the nearest available working time slot following a given DATE.

ext\workingTime\findClosestWorkingTime()
ext\workingTime\findClosestWorkingTime(DATE, [ENTITY_TYPE, ENTITY_ID]): STRING|NULL

Example:

ext\workingTime\findClosestWorkingTime() Example
$nextWorkingTimeSlot = ext\workingTime\findClosestWorkingTime(datetime\now());

Note

Working Time Calendars are structured across three tiers:

  1. Default: This is the System Level Working Time Calendar.
  2. Team: Pertains to the Team Level Working Time Calendar.
  3. User: Relates to the User Level Working Time Calendar.

For operations that require specificity, optional parameters such as [ENTITY_TYPE] and [ENTITY_ID] can be utilised, designated as either 'User' or 'Team', followed by the corresponding ID of the user or team.


ext\workingTime\getSummedWorkingHours( )

The ext\workingTime\getSummedWorkingHours() function calculates the cumulative number of working hours within a specified date range.

ext\workingTime\getSummedWorkingHours()
ext\workingTime\getSummedWorkingHours(FROM, TO, [ENTITY_TYPE, ENTITY_ID]): FLOAT

Example:

ext\workingTime\getSummedWorkingHours() Example
$totalWorkingHours = ext\workingTime\getSummedWorkingHours(datetime\now(), datetime\addDays(datetime\now(), 10));

Note

Working Time Calendars are structured across three tiers:

  1. Default: This is the System Level Working Time Calendar.
  2. Team: Pertains to the Team Level Working Time Calendar.
  3. User: Relates to the User Level Working Time Calendar.

For operations that require specificity, optional parameters such as [ENTITY_TYPE] and [ENTITY_ID] can be utilised, designated as either 'User' or 'Team', followed by the corresponding ID of the user or team.


ext\workingTime\getWorkingDays( )

The ext\workingTime\getWorkingDays() function returns the number of working days between two dates.

ext\workingTime\getWorkingDays()
ext\workingTime\getWorkingDays(FROM, TO, [ENTITY_TYPE, ENTITY_ID]): INTEGER

Example:

ext\workingTime\getWorkingDays() Example
$currentDate = datetime\today();
$dueDate = ext\workingTime\addWorkingDays($currentDate, 10);

$numberOfWorkingDays = ext\workingTime\getWorkingDays($currentDate, $dueDate);

Note

Working Time Calendars are structured across three tiers:

  1. Default: This is the System Level Working Time Calendar.
  2. Team: Pertains to the Team Level Working Time Calendar.
  3. User: Relates to the User Level Working Time Calendar.

For operations that require specificity, optional parameters such as [ENTITY_TYPE] and [ENTITY_ID] can be utilised, designated as either 'User' or 'Team', followed by the corresponding ID of the user or team.


ext\workingTime\hasWorkingTime( )

The ext\workingTime\hasWorkingTime() function checks if there are any working hours within a specified date range and returns a boolean value indicating the result.

ext\workingTime\hasWorkingTime()
ext\workingTime\hasWorkingTime(FROM, TO, [ENTITY_TYPE, ENTITY_ID]): BOOLEAN

Example:

ext\workingTime\hasWorkingTime() Example
$currentDate = datetime\today();
$dueDate = datetime\addDays($currentDate, 20);
$hasWorkingTime = ext\workingTime\hasWorkingTime($currentDate, $dueDate);

Note

Working Time Calendars are structured across three tiers:

  1. Default: This is the System Level Working Time Calendar.
  2. Team: Pertains to the Team Level Working Time Calendar.
  3. User: Relates to the User Level Working Time Calendar.

For operations that require specificity, optional parameters such as [ENTITY_TYPE] and [ENTITY_ID] can be utilised, designated as either 'User' or 'Team', followed by the corresponding ID of the user or team.


ext\workingTime\isWorkingDay( )

The ext\workingTime\isWorkingDay() function checks if a given date falls on a working day and returns a boolean value indicating the result.

ext\workingTime\isWorkingDay()
ext\workingTime\isWorkingDay(DATE, [ENTITY_TYPE, ENTITY_ID]): BOOLEAN

Example:

ext\workingTime\isWorkingDay() Example
$currentDate = datetime\today();
$dueDate = datetime\addDays($currentDate, 20);
$isWorkingDay = ext\workingTime\isWorkingDay($currentDate, $dueDate);

Note

Working Time Calendars are structured across three tiers:

  1. Default: This is the System Level Working Time Calendar.
  2. Team: Pertains to the Team Level Working Time Calendar.
  3. User: Relates to the User Level Working Time Calendar.

For operations that require specificity, optional parameters such as [ENTITY_TYPE] and [ENTITY_ID] can be utilised, designated as either 'User' or 'Team', followed by the corresponding ID of the user or team.


See Also