Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Script to pdate the Prioirty automatically whenvere it changed

Sharadkumar Bangera
Contributor
November 16, 2020

Hello,

 

I  am looking for Script runner with detailed step which fulfils my requirements

My requirement is whenever we change the priority in jira it displays normally Priority changed from Major to Minor but it does not display the same message in service portal which customer refer. Customer is always blind in service portal when the priority is changed

Hence i am looking or a script runner whenever we change the priority from Major to minor in Jira the comment to be automatically added in Service portal which is visible to customer "The priority for this issue has changed from Major to Minor"

I am aware it works with "Automation for Jira - Server" but i dont have this application and looking for only script runner

Thanks and Regards,

Sharad

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Raziman Dom - Ricksoft
Community Champion
October 7, 2020

Hi Peter,

You can fix it by change:

String jsValue = issue.getCustomFieldValue(jsField).toString()
String cdValue = issue.getCustomFieldValue(cdField).toString()

To:

def jsValue = issue.getCustomFieldValue(jsField) as Double
def cdValue = issue.getCustomFieldValue(cdField).toString() as Double

Remove:

//int jsInt = Integer.parseInt(jsValue)
//int cdInt = Integer.parseInt(cdValue)

//def wsjfValue = cdValue/jsValue

Return:

return cdValue/jsValue

So your final code should be:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

CustomField jsField = customFieldManager.getCustomFieldObject("customfield_15123")

CustomField cdField = customFieldManager.getCustomFieldObject("customfield_15126")

CustomField wsjfField = customFieldManager.getCustomFieldObject("customfield_15128")

def jsValue = issue.getCustomFieldValue(jsField) as Double
def cdValue = issue.getCustomFieldValue(cdField) as Double

return cdValue/jsValue

It is recommended to return as Double and not Integer since you are dividing the 2 numbers. 

Anirudh Pratap Verma
November 22, 2024

Hi,

 

But this will not work in Jira Cloud as it is using several classes applicable for server.

TAGS
AUG Leaders

Atlassian Community Events