Hi ,
I want to write script in script runner for workflow in between transition for validators to check the issue link is enter or not (tested by OR created by) any one of link has to enter in the transition.
So please let me know your inputs and help me out.
Thanks in advance,
Regards,
Syamala.Y
It would be something like this (you should add this as condition in a simple script validator):
import com.atlassian.jira.component.ComponentAccessor
if (issue.issueType.name == 'Tarea IT'){ //checks the issuetype in case you don't want to apply to everyone
if (cfValues['linked issues']) return true; //You have to check here the kind of links
return false;
}
return true
Thanks for your input.
I have written below code in script runner but getting error in 4th line "Linked Issues" that field does not exists or multiple field exists for the same name.
import com.atlassian.jira.component.ComponentAccessor
if (issue.issueType.name == 'Story'){ //checks the issuetype in case you don't want to apply to everyone
if (cfValues['Linked Issues']) return true; //You have to check here the kind of links
return false;
}
return true
So could please help me out.
Regards,
Syamala.Y
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My bad, i gave half the solution.
We had to use a workaround. I try to explain it completely.
The trouble is that you can't check as a validator the linked issues, there is no information until the issue is created.
The workaround was adding a new field, check that field in the validator with the code i added there and then copy the value of that field as a postfunction with the issueLink Manager.
Step by step
import com.atlassian.jira.component.ComponentAccessor
log.warn(issue.issueType.name)
if (issue.issueType.name == 'Story'){
if (cfValues['Linked Issues']) return true;
return false;
}
return true
with this, that field is required for the issuetype you need in case you need to apply only to some issue types.
4. Create a postfunction with this script
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
//uncomment to check in console
//
//def issueManager = ComponentAccessor.getIssueManager()
//def issue = issueManager.getIssueObject("AE-82")
//end of check in console
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def userManager = ComponentAccessor.userManager
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.getIssueManager()
CustomField field = customFieldManager.getCustomFieldObjectByName('Linked Issues')
def clave = field.getValue(issue).toString()
def issueenlazada = issueManager.getIssueObject(clave)
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager();
issueLinkManager.createIssueLink(issue.getId(), issueenlazada.getId(), 10400, 1, user)
That 10400 on the last line is the type of link you want that issuelink to be, in my case complements. This is the complete list
10000 | Blocks | is blocked by | blocks | |
10001 | Cloners | is cloned by | clones | |
10002 | Duplicate | is duplicated by | duplicates | |
10003 | Relates | relates to | relates to | |
10100 | jira_subtask_link | jira_subtask_inward | jira_subtask_outward | jira_subtask |
10200 | Epic-Story Link | has Epic | is Epic of | jira_gh_epic_story |
10300 | Gantt End to Start | has to be done after | has to be done before | |
10301 | Gantt Start to Start | has to be started together with | has to be started together with | |
10302 | Gantt End to End | has to be finished together with | has to be finished together with | |
10303 | Gantt Start to End | start is earliest end of | earliest end is start of | |
10400 | Complements | Is complemented by | Complements | |
10500 | Problem/Incident | is caused by | causes | servicedesk_automation_default_linktype |
And that's all.
A little bit messy but it's working for me.
Sorry i gave you false hope of this being very much easier
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are some useful examples of validators at https://library.adaptavist.com/search?q=validator
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.