Note

We've packed up and moved from Confluence to Discourse to bring you a better, more interactive space. Out of courtesy we didn't migrate your user account so - you will have to signup again

The Exalate team will be on holiday for the coming days - returning Jan 4
Enjoy & stay safe

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagegroovy
themeRDark
titleIncoming sync
// createBy default atempo variablesends withover the integer datatype
def time =in 0seconds.
// IterateIterates over logged thetime
def workLogtotalTimeInSeconds items= 0
for(int i = 0; i < replica.workLogs.size(); i++){
	    totalTimeInSeconds += replica.workLogs[i].timeSpent
}

// This will add every logged time to the "time" variable
	time += replica.workLogs[i]?.timeSpent.toInteger() / 60 function makes the time readable.
def convertToReadableTime(long seconds){
    def hour = (int)Math.floor(seconds / 3600)
    seconds %= 3600
    def minutes = (int)Math.floor(seconds / 60)
    if(hour == 0){
        return "${minutes.toString()}m"
    }
    return "${hour.toString()}h:${minutes.toString()}m"
}
// SetAdd the customfield value to the total logged time and converts it back to a string
entity."servicenow_customField_name" = time.toString( your custom field, by calling the "convertToReadableTime" function with the "totalTimeInSeconds" as parameter.
workItem.customFields."Tempo Worklogs".value = convertToReadableTime(totalTimeInSeconds)



Full video how to do it:

...