Hello,
After a bug resolved in our script we are experiencing problems with duplication of logs which are entered manually on the receiving site. We sync two Jira cloud sites and using Tempo for the workLogs. Here is the script we are trying to implement but it pops an error on line 23(the filtering) which suggests that the solution is to duplicate the parsed workLog but is does not help. Our goal is to sync workLogs after the start of February 2025. I am posting the outgoing script we are using. Some help will be much appreciated.
issue.workLogs = workLogHelper.mergeWorkLogs(issue, replica).findAll { workLog →
workLog.created > new Date().parse(“yyyy-MM-dd”, “2024-02-01”)
}
I am adding the error:
No signature of method: java.util.Date.parse() is applicable for argument types: (String, String) values: [yyyy-MM-dd, 2024-02-01] Possible solutions: parse(java.lang.String), wait(), clone(), any(), grep(), putAt(java.lang.String, java.lang.Object)
I understand Ariel has already shared a solution with you—thanks for that, @Ariel_Aguilar! I’ll also provide the solution here so that other users can benefit from it as well.
To prevent syncing duplicate Tempo work logs and ensure that only work logs within a specific date range are synchronized, you can use the following script:
Outgoing Sync Jira Cloud
import java.text.SimpleDateFormat
// Trigger the Tempo work log sync
TempoWorkLogSync.send(
"ABC", // Replace with your actual Tempo access token
replica,
issue,
httpClient,
nodeHelper
)
// Define the cutoff date to filter work logs
def dateFormat = new SimpleDateFormat("yyyy-MM-dd")
def cutoffDate = dateFormat.parse("2025-04-01")
// Keep only work logs starting after the specified date
replica.workLogs = replica.workLogs.findAll { workLog ->
workLog.startDate.after(cutoffDate)
}
This script ensures that only work logs with a startDate after April 1st, 2025 are synced, helping avoid duplication and keeping your data clean and within the desired timeframe.