Skip to content

Instantly share code, notes, and snippets.

@iaindooley
Created April 22, 2019 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iaindooley/3b5bd2fdd8f327fa8fe750e82bd6d587 to your computer and use it in GitHub Desktop.
Save iaindooley/3b5bd2fdd8f327fa8fe750e82bd6d587 to your computer and use it in GitHub Desktop.
Set Custom Field Values From Due Date
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