Created
April 22, 2019 23:21
-
-
Save iaindooley/3b5bd2fdd8f327fa8fe750e82bd6d587 to your computer and use it in GitHub Desktop.
Set Custom Field Values From Due Date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setCustomFieldValuesFromDueDate(notification) | |
{ | |
//Will trigger for adding or editing a due date | |
var card = new Notification(notification).addedDueDate(); | |
//Set these offsets accordingly. The element name is the | |
//name of the field (eg. production stage) and the value | |
//is offset in days, plus or minus | |
var offsets = {"Field 1": -1, | |
"Field 2": -3, | |
"Field 3": -7}; | |
new IterableCollection(offsets).each(function(value,key) | |
{ | |
//This will create fields as text type if they | |
//don't exist, and enable the power up if not enabled. | |
//If you want to use these as dates later, make sure the | |
//fields already exist before running the function as Date | |
//types | |
card.setCustomFieldValue(key,new Date(card.due()).addDays(value)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment