Created
May 13, 2019 01:38
-
-
Save iaindooley/4912f45b758578b06cbc9a687c8d019f to your computer and use it in GitHub Desktop.
Timesheet Entry From Custom Field
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 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