-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelperFunctions.js
32 lines (29 loc) · 987 Bytes
/
helperFunctions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Sets a range to hyperlink with a Jira key as the text
*
* @param {range} range Range where the hyperlink will go.
* @param {string} jiraKey Jira key text shown in the cell (ex: ABC-123)
* @param {baseurl} baseurl URL of the jira instance URL.
* @customfunction
*/
function setCellURLKey(range, jiraKey, baseurl) {
var richValue = SpreadsheetApp.newRichTextValue()
.setText(jiraKey)
.setLinkUrl(baseurl + jiraKey)
.build();
range.setRichTextValue(richValue);
}
/**
* Sets a string to Proper/Title case. From: https://stackoverflow.com/questions/23439300/converting-string-to-proper-title-case-in-google-apps-script
*
* @param {str} str String to be converted to Proper case
* @return Proper case function
* @customfunction
*/
function toTitle(str) {
return str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0)
.toUpperCase() + txt.substr(1)
.toLowerCase();
});
}