Skip to content

Instantly share code, notes, and snippets.

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/4912f45b758578b06cbc9a687c8d019f to your computer and use it in GitHub Desktop.
Save iaindooley/4912f45b758578b06cbc9a687c8d019f to your computer and use it in GitHub Desktop.
Timesheet Entry From Custom Field
function timeSheetEntryFromCustomField(notification)
{
var notif = new Notification(notification);
var field = notif.changedCustomField("End Time");
var end = field.value();
var start = field.card().customFieldValue("Start Time");
try
{
var hours = createXeroTimesheetEntryViaApi(notif.member().name(),notif.board().name(),start,end);
//Let the user know it was successful
notif.replyToMember("thanks, recorded "+hours+" hours");
//Reset for next timesheet entry
field.card().setCustomFieldValue("Start Time","").setCustomFieldValue("End Time");
}
catch(e)
{
notif.replyToMember("Whoa! Something went wrong. Find the nearest IT person and give them this message: "+e);
}
}
/**
* Gets the email of a team member from their username,
* then posts a timesheet entry for the given client
*/
function createXeroTimesheetEntryViaApi(username,client_name,start,end)
{
//NEEDS TO BE IMPLEMENTED VIA XERO API
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment