Hello,
in our "change management" process we normally raise an issue from type "suggestion" which gets cloned into a "request" issuetype and finally gets cloned into a "change" type issue. To track several fields like "release date" and stuff we implemented a script fragment panel and a script listener which gets displayed in the "request" issuetype and shows relevant data from the "change" issuetype.
Problem: In our issue search and furthermore our gadgets and reporting dashboards the initial issuetype "suggestions" now also shows data in fields like "release date". But these fields are only configured and relevant for "changes" and get synchronized backwards to the script runner web panel displayed in "requests". We use the following script to fill the web panel fragment:
ApplicationUser superuser = ComponentAccessor.userManager.getUserByName("superuser")
def issueManager = ComponentAccessor.getIssueManager()
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("DD/MM/YYYY");
String formattedDate = dateFormat.format(date);
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager()
List<IssueLink> inwardLinks = issueLinkManager.getInwardLinks(event.issue.getId())
// CustomField implementationIssue = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11572");
CustomField implementationStatus = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11601");
CustomField implementationManager = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12600");
CustomField readyPlan = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12605");
CustomField readyIs = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12604");
CustomField releasePlan = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12606");
CustomField releaseIs = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12607");
CustomField release = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11400");
CustomField changeManager = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10315");
for (IssueLink issueLink : inwardLinks){
Issue destination = issueLink.getDestinationObject()
Issue source = issueLink.getSourceObject()
MutableIssue mutableSource = source as MutableIssue
MutableIssue mutableDestination = destination as MutableIssue
if (issueLink.issueLinkType.name == "link" && source.getProjectId() == 10100L && destination.getProjectId() != 10100L) {
log.debug("ID parent: " + mutableSource.getId())
log.debug("Key Parent: " + mutableSource.getKey())
mutableSource.setCustomFieldValue(implementationStatus , destination.getStatus().getSimpleStatus().getName().toString())
mutableSource.setCustomFieldValue(implementationManager , destination.getCustomFieldValue(changeManager));
mutableSource.setCustomFieldValue(readyPlan, destination.getCustomFieldValue(readyPlan ))
mutableSource.setCustomFieldValue(readyIs, destination.getCustomFieldValue(readyIs))
mutableSource.setCustomFieldValue(releasePlan, destination.getCustomFieldValue(releasePlan))
mutableSource.setCustomFieldValue(releaseIs, destination.getCustomFieldValue(releaseIs))
mutableSource.setCustomFieldValue(release, destination.getCustomFieldValue(release))
issueManager.updateIssue(superuser, mutableSource, EventDispatchOption.ISSUE_UPDATED, false)
issueManager.updateIssue(superuser, mutableDestination, EventDispatchOption.ISSUE_UPDATED, false)
log.debug("Ready")
} else {
log.debug("Project not BRM")
}
}
}