Originally asked by Salma Nairi on 29 December 2020 (original question)
Hi with new version 5.0.6, the Sprint value is overwritten to null on each update could you please help us to solve this and can we just sync sprint as custom field without syncing a board thanks
Remote Side :
Incoming
if(entityType == “sprint”){
//Executed when receiving a sprint sync from the remote side
def sprintMap = [“126”:“26”] //[remoteBoardId: localBoardId]
sprint.name = replica.name
sprint.goal = replica.goal
sprint.state = replica.state?.toUpperCase()
sprint.startDate = replica.startDate
sprint.endDate = replica.endDate
def localBoardId = sprintMap[replica.originBoardId]
if(localBoardId == null){
throw new com.exalate.api.exception.IssueTrackerException("No board mapping for remote board id "+replica.originBoardId)
}
sprint.originBoardId = localBoardId //Set the board ID where the sprint will be created
}
if(entityType == “issue”){
if(firstSync){
// If it’s the first sync for an issue (local issue does not exist yet)
// Set project key from source issue, if not found set a default
issue.projectKey = “SAT4”
issue.type = replica.type
issue.typeName = replica.typeName
issue.summary = replica.summary
issue.description = replica.description
issue.components = replica.components.collect{
nodeHelper.createComponent(
issue,
it.name,
it.description,
it.leadKey,
it.assigneeType.name()
)
}
issue.affectedVersions += replica.affectedVersions
.collect { v -> nodeHelper.createVersion(issue, v.name, v.description) }
issue.priority =replica.priority
issue.customFields.“Frequency”?.value = replica.customFields.“Frequency” ?.value?.value
issue.issueLinks = replica.issueLinks
issue.customFields.“Severity”?.value = replica.customFields.“Severity” ?.value?.value
issue.customFields.“Is Regression”?.value = replica.customFields.“Is Regression” ?.value?.value
//SimpleSprintSync.receive()
def sprintV = replica.customFields.Sprint?.value?.id.collect{ remoteSprintId ->
return nodeHelper.getLocalIssueKeyFromRemoteId(remoteSprintId, “sprint”)?.id?.toString()}.findAll{it != null}
issue.customFields.“Sprint”.value = sprintV
}
issue.typeName = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name
issue.summary = replica.summary
issue.description = replica.description
issue.components = replica.components.collect{
nodeHelper.createComponent(
issue,
it.name,
it.description,
it.leadKey,
it.assigneeType.name()
)
}
issue.affectedVersions += replica.affectedVersions
.collect { v -> nodeHelper.createVersion(issue, v.name, v.description) }
issue.fixVersions = replica.fixVersions
.collect { v -> nodeHelper.createVersion(issue, v.name, v.description) }
issue.priority =replica.priority
issue.customFields.“Is Regression”?.value = replica.customFields.“Is Regression” ?.value?.value
issue.customFields.“Frequency”?.value = replica.customFields.“Frequency” ?.value?.value
issue.customFields.“Severity”?.value = replica.customFields.“Severity” ?.value?.value
IssueLinks.receive()
///////// Here is a strange behavior , value is overwritten to null
def sprintV = replica.customFields.Sprint?.value?.id.collect{ remoteSprintId ->
return nodeHelper.getLocalIssueKeyFromRemoteId(remoteSprintId, “sprint”)?.id?.toString()}.findAll{it != null}
issue.customFields.“Sprint”.value = sprintVSimpleSprintSync.receive()
}
Local Side
def boardIds = [“126”] //Boards which sprints will get synced
if(entityType == “sprint” && boardIds.find{it == sprint.originBoardId}){
replica.name = sprint.name
replica.goal = sprint.goal
replica.state = sprint.state
replica.startDate = sprint.startDate
replica.endDate = sprint.endDate
replica.originBoardId = sprint.originBoardId
}
if(entityType == “issue”){
replica.key = issue.key
replica.project = issue.project
replica.type = issue.type
replica.typeName = issue.typeName
replica.summary = issue.summary
replica.description = issue.description
replica.components = issue.components
replica.affectedVersions = issue.affectedVersions
replica.fixVersions = issue.fixVersions
replica.priority = issue.priority
replica.customFields.“Is Regression” = issue.customFields.“Is Regression”
replica.customFields.“Frequency” = issue.customFields.“Frequency”
replica.customFields.“Severity” = issue.customFields.“Severity”
IssueLinks.send()
replica.status = issue.status
replica.customFields.Sprint = issue.customFields.Sprint
}