Originally asked by Mathavan on 04 May 2023 (original question)
Hi Team,
We have tried to sync “Time Tracking” fields from Jira server to Jira server.
Unable to sync it, Can you please help us to fix as early as possible.
We refered this documentation : https://docs.exalate.com/docs/how-to-sync-time-tracking-fields-in-jira-cloud
Its not working
Outgoing Sync:
replica.timeSpent = issue.timeSpent
replica.originalEstimate = issue.originalEstimate
replica.remainingEstimate = issue.remainingEstimate
Incoming Sync:
if(firstSync)
{
Map<String, String> projectKeys = new HashMap<String, String>();
projectKeys.put(“TPFEBS”,“AVNSTDG6”);
Map<String, Map<String,String>> projectIssueTypesMapping = new HashMap<String, Map<String,String>>();
projectIssueTypesMapping.put(“TPFEBS”,getMapForString(“Story:Bug”));
if(projectKeys.containsKey(replica.project.key) && projectIssueTypesMapping.containsKey(replica.project.key))
{
Map<String,String>projectIssueType = projectIssueTypesMapping.get(replica.project.key);
if(projectIssueType.containsKey(replica.type.name))
{
issue.projectKey = projectKeys.get(replica.project.key);
issue.typeName = projectIssueType.get(replica.type.name);
if(replica.timeSpent !\= null)
issue.timeSpent.value \= replica.timeSpent.value
if(replica.originalEstimate !\= null)
issue.originalEstimate.value \= replica.originalEstimate.value
if(replica.remainingEstimate !\= null)
issue.remainingEstimate.value \= replica.remainingEstimate.value
}
}
else
{
if(replica.timeSpent != null)
issue.timeSpent.value = replica.timeSpent.value
if(replica.originalEstimate !\= null)
issue.originalEstimate.value \= replica.originalEstimate.value
if(replica.remainingEstimate !\= null)
issue.remainingEstimate.value \= replica.remainingEstimate.value
}
}
public static Map<String,String> getMapForString(String values)
{
Map<String,String> temp = new HashMap<String,String>();
String items = values.split(“,”);
for(String item:items)
{
String subItems = item.split(“:”);
temp.put(subItems[0], subItems[1]);
}
return temp;
}
Thanks,
Mathavan Mathiyalagan
Comments:
M. Ashar Iqbal commented on 13 October 2023
Hi Mathavan ,
Could you please try this out, and let me know if you experience any error?
Incoming Sync rule Expand source
if (firstSync) {
Map projectKeys = new HashMap<>()
projectKeys.put("TPFEBS", "AVNSTDG6")
Map> projectIssueTypesMapping = new HashMap<>()
projectIssueTypesMapping.put("TPFEBS", getMapForString("Story:Bug"))
if (projectKeys.containsKey(replica.project.key) && projectIssueTypesMapping.containsKey(replica.project.key)) {
Map projectIssueType = projectIssueTypesMapping.get(replica.project.key)
if (projectIssueType.containsKey(replica.type.name)) {
issue.projectKey = projectKeys.get(replica.project.key)
issue.typeName = projectIssueType.get(replica.type.name)
if (replica.timeSpent != null) {
issue.timeSpent.value = replica.timeSpent.value
}
if (replica.originalEstimate != null) {
issue.originalEstimate.value = replica.originalEstimate.value
}
if (replica.remainingEstimate != null) {
issue.remainingEstimate.value = replica.remainingEstimate.value
}
}
} else {
if (replica.timeSpent != null) {
issue.timeSpent.value = replica.timeSpent.value
}
if (replica.originalEstimate != null) {
issue.originalEstimate.value = replica.originalEstimate.value
}
if (replica.remainingEstimate != null) {
issue.remainingEstimate.value = replica.remainingEstimate.value
}
}
}
public static Map getMapForString(String values) {
Map temp = new HashMap<>()
String[] items = values.split(",")
for (String item : items) {
String[] subItems = item.split(":")
temp.put(subItems[0], subItems[1])
}
return temp
}
Thank you,
Ashar
Support Engineer; Exalate