Hello,
I tried to make a post function, that copy from the parent (Bug-Internal type) of an issue (QVR type) the value of custom field 'Resolution' .. and insert this value into custom field of the issue 'Reason' (Text field)
I didn't success to get the parent at all.. It tell me that I get null.
This is my code, Any ideas how can it works? ->
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import com.atlassian.jira.issue.util.IssueChangeHolder;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.*
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.ModifiedValue;
def issueManager = ComponentAccessor.getIssueManager();
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
//test
//Issue issue = issueManager.getIssueObject("WBL-57142");
//Get QVR 'Reason' field
CustomField Reason = customFieldManager.getCustomFieldObjectByName("Reason");
//Get Bug-Internal issue
try {
def issueLink = issueLinkManager.getOutwardLinks(issue.getId());
//Get key of linked issue="is Bug Of QVR"
def key=issueLink[0].getDestinationObject();
key=key.toString();
//Get Bug linked issue
Issue Bug = issueManager.getIssueObject(key);
log.warn Bug;
//Get resolution value
def ResolutionField = Bug.getResolution().name;
log.warn ResolutionField
//update 'Reason' field of issue
def changeHolder = new DefaultIssueChangeHolder();
Reason.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(Reason), ResolutionField),changeHolder);
} catch (e) {
log.warn e.message;
}
Hello @Dan27
What is relation between "Bug-Internal type" and "QVR type"
Are they just linked or have task : sub-task relation?
If second, you ll need to use
def parent = issue.getParentObject()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Find an error in your code. getDestinationObject() method returns Issue object, so you dont need to get it later. Try like this
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import com.atlassian.jira.issue.util.IssueChangeHolder;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.*
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.ModifiedValue;
def issueManager = ComponentAccessor.getIssueManager();
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
//test
//Issue issue = issueManager.getIssueObject("WBL-57142");
//Get QVR 'Reason' field
CustomField Reason = customFieldManager.getCustomFieldObjectByName("Reason");
//Get Bug-Internal issue
try {
def issueLink = issueLinkManager.getOutwardLinks(issue.getId());
//Get key of linked issue="is Bug Of QVR"
def bug =issueLink[0].getDestinationObject();
//key=key.toString();
//Get Bug linked issue
//Issue Bug = issueManager.getIssueObject(key);
log.warn bug;
//Get resolution value
def ResolutionField = bug.getResolution().name;
log.warn ResolutionField
//update 'Reason' field of issue
def changeHolder = new DefaultIssueChangeHolder();
Reason.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(Reason), ResolutionField),changeHolder);
} catch (e) {
log.warn e.message;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank @Mark Markov ,
It wrote for me this error:
Cannot invoke method getDestinationObject() on null object
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This means that issue doesnt have any outward links.
May be link inward?
try
def issueLink = issueLinkManager.getInwardLinks(issue.getId());
instead of
def issueLink = issueLinkManager.getOutwardLinks(issue.getId());
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.