Beside standard Velocity constructs like @last @first, $ myarray . isEmpty () or $ myarray . empty  there are several helpers which can address specific problems when running Raley notifications.


boolean $raley.isAfter($firstDate, $secondDate)

Used to compare if $firstDate is after $secondDate. Both dates must be either in yyyy-MM-dd  or  yyyy-MM-dd'T'HH:mm:ss.SSSZ  formats.

Typical use cases of this function is checking whether update of the issue happened after $context.today or $context.yesterday or $context. onehourago. For example, checking whether issue was updated in last hour or since yesterday.


boolean $raley.isSameUpdate($firstDate, $secondDate)

Checks whether the difference between $firstDate and $secondDate is less than 1 second. This is useful to check whether issue update and comment created happened during the same logical update.

Both dates must be in format yyyy-MM-dd'T'HH:mm:ss.SSSZ


String $raley.settingValue($key)

This function retrieves value from Settings based on $key supplied. Settings are basically collection of key=value pairs and they are helpful if you need, for example, to find out user's channel from his email.


String $raley.formatDate($dateValue, $format)

Formats given $dateValue date using format in $format. If $format is omitted then MM-dd-yy hh:mm will be used.



$raley.includeAttachments($pattern)

Sends attachments from current Issue to email/slack/hipchat. $pattern defines extensions that attachment must match against. If not specified then all.


$raley.customBotAvatar($customBotAvatarUrl)

Customises Slack avatar of raley bot. $customBotAvatarUrl must be an absolute URL of avatar image.


$raley.groupEmails("JIRA_GROUPNAME")

Retrieves a comma-separated list of emails of JIRA users belonging to specified JIRA group


$raley.serviceDeskCustomersEmails("JIRA_PROJECT_KEY")

Retrieves a comma-separated list of emails of all customers in a ServiceDesk that's associated with given Jira project key


$raley.calculateAgeDays($!issue.fields.created)

Returns age of an issue in days


$raley.userProperty($userKey, $propertyName)

Allows you to retrieve a value of JIRA property for the specified user key.  


$raley.convertAndFormatDate($dateValue, $timezone, $format)

Parses the date from $dateValue and outputs it in given $format with specified $timezone. Timezone code must be one value from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones in column TZ*


$raley.collectMentions($JiraTextOrTextAreaField)

Given the Jira field, find users mentioned in it and return a collection of user objects. Every object has the following properties: accountId, displayName, emailAddress


$raley.interval ($firstDate, $secondDate, $unit)

Given two dates or datetimes in one of Jira cloud format: 

yyyy-MM-dd'T'HH:mm:ss.SSSZ
MM-dd-yy hh:mm
yyyy-MM-dd
yyyy-MM-dd HH:mm
Find the absolute number of DAYS or HOURS between first and second date. Third argument ($unit) must be of value either "DAYS" or "HOURS"

$raley.resolveNames ($inputCommentString)

Will search for occurrence of mentions that contain accountid and replace the accountid to fullname of mentioned user


$raley.attachThumbnailTargets()

For each attachment that is appended inline and has a target image Raley will add the TARGET image as a regular file attachment. This way, if your email client is able to handle inline attachments properly - everything will work smoothly. But if your client is tricky like (MS Outlook), then the target image will still appear as a separate attachment - only the embedded thumbnail link won't work.


$raley.getNewElements($from, $to)
Returns a java.util.List that you can later iterate on which contains all values from $to that are not present in $from.
Both, $from and $to should be comma-separate values. Empty strings and nulls are allowed


$raley.approveButton($issue, $customFieldCode)

Generates Approve button to be rendered in email. You need to pass $issue data as is, i.e. $issue and for $customFieldCode you need to pass the code for the custom field that keeps approvals in your system. For example:

$raley.approveButton($issue, "customfield_10118")


$raley.approveButtonWithLabel($issue, $customFieldCode, $label)

Generates Approve button to be rendered in email with specific label. You need to pass $issue data as is, i.e. $issue and for $customFieldCode you need to pass the code for the custom field that keeps approvals in your system. For example:

$raley.approveButton($issue, "customfield_10118", "Agree")


$raley.approveButtonWithLabelAndCSS($issue, $customFieldCode, $label, $customCss)

Generates Approve button to be rendered in email with specific label. You need to pass $issue data as is, i.e. $issue and for $customFieldCode you need to pass the code for the custom field that keeps approvals in your system. For example:

$raley.approveButtonWithLabelAndCSS($issue, "customfield_10118", "Agree", "background-color: green")



$raley.declineButton($issue, $customFieldCode)

Generates Decline button to be rendered in email. You need to pass $issue data as is, i.e. $issue and for $customFieldCode you need to pass the code for the custom field that keeps approvals in your system. For example:

$raley.declineButton($issue, "customfield_10118")


$raley.declineButtonWithLabel($issue, $customFieldCode, $label)

Generates Decline button to be rendered in email with specific label. You need to pass $issue data as is, i.e. $issue and for $customFieldCode you need to pass the code for the custom field that keeps approvals in your system. For example:

$raley.declineButton($issue, "customfield_10118", "Disagree")



$raley.declineButtonWithLabelAndCSS($issue, "customfield_10032", "Not OK", $customCss)

Generates Decline button to be rendered in email with specific label. You need to pass $issue data as is, i.e. $issue and for $customFieldCode you need to pass the code for the custom field that keeps approvals in your system. For example:

$raley.declineButtonWithLabelAndCSS($issue, "customfield_10118", "Disagree", "background-color: red")


$raley.timetrackingAttribute($attributeName, $timetracking)

Parses Jira timetracking field looking for component with key $attributeName and returns its value.

The value of $attributeName can be one of the following: 

  • originalEstimateSeconds
  • timeSpentSeconds
  • timeSpent
  • remainingEstimate
  • remainingEstimateSeconds
  • originalEstimate

Usage example: $raley.timetrackingAttribute("remainingEstimate", $issue.renderedFields.timetracking)


String $raley.formatNumber($numberValue, $format)

Formats given $numberValue using format in $format. Standard Java DecimalFormats are supported. The $numberValue parameter must be of type java.lang.Double


$raley.emailHeader($headerName, $headerValue)

Adds email headers to outgoing email. $headerName represents a header name and $headerValue - header value as string


$raley.customEmailFrom($value)

Allows to provide dynamic value for email "From name". This can be a hardcoded constant or a value from $issue, like $issue.fields.assignee.displayName


$raley.customEmailFromAddress($value)

Allows to provide dynamic value for email "From" address. This can be a hardcoded constant or a value from $issue, like $issue.fields.assignee.emailAddress


$raley.hasJiraPermisison($accountId, "JIRA_PERMISSION_CODE", $projectId)

Checks if a Jira user specified by $accountId has a Jira permission specified by JIRA_PERMISSION_CODE in project $projectId.

You can get a list of valid values for JIRA_PERMISSION_CODE by opening https://YOUR_JIRA_INSTANCE.atlassian.net/rest/api/3/permissions in your browser

Usage example:  

#if ($raley.hasJiraPermisison($u.accountId, "SERVICEDESK_AGENT", $issue.fields.project.id))
    $!u.emailAddress, 
#end


$raley.organizationEmails($organizationId)

Retrieves comma-separated list of users' emails from specific organization.

Example of usage:

#foreach ($o in $!issue.fields.customfield_10001)
    $raley.organizationEmails($!o.id),
#end

 

$raley.resolveEmails($accountIds)

Given a java.util.List of account IDs. Returns a list of email addresses resolved from those accounts.

Usage example, resolving emails of newly added request participants:

#foreach ($ic in $issue.lastchange.items)
  #if ($ic.fieldId == "customfield_10103") 
        $raley.resolveEmails($raley.getNewElements($ic.from, $ic.to))
  #end
#end


$raley.projectOrganizations(String projectKey)

Given a project key or service desk ID, return a Set of organization ID's that are defined in the given project/service_desk
Usage example: retrieve all organizations' emails from given project key:

#set($orgs = $raley.projectOrganizations($issue.fields.project.key))
#foreach ($org in $orgs)
  $raley.organizationEmails($org) ,
#end


$raley.referEmailsWithSameIssueKey()

Adds References headers to refer to all emails sent out by raley for the same issue key no matter which notification configuration actually sent it. By default, References header is only added to emails sent by the same notification configuration.  


$raley.addToReferencesHeader($value)

Adds a value specified by $value to the list of References header in email


$raley.getAssetFieldValue(objectId, objectKey)

Retrieves an Assets object identified by objectId and returns an attribute which name equals to objectKey as string


$raley.getAssetFieldValues(objectId, objectKey)

Retrieves an Assets object identified by objectId and returns values of the attribute identified by objectKey. The returned value is List of String objects.


$raley.getWebLinks($issueKey)

Retrieves a collection of web links for the given ticket. Every element in collection has the following properties:

id - numeric id of weblink

globalId - global id of weblink (String)

title - name of the weblink

url - address of weblink


$raley.getCommentPropertiesKeys($commentId)

Retrieves a Set of comment keys that are associated with given comment. Example usage - we need to check if a comment was added via email or portal:

#set($props = $raley.getCommentPropertiesKeys($issue.lastcomment.id))
#set($isFromEmail = $props.contains("sd.comment.email.email.list"))
Is from Email=$isFromEmail