Forums

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

The script runner is changing the status back

Anuradha Yadav
Contributor
January 20, 2021

Hi Team,

Can i get help on below snip? Why is this suddenly happening? any idea?

image.png

 

2 answers

1 accepted

0 votes
Answer accepted
Mohamed Benziane
Community Champion
January 20, 2021

Hello @Anuradha Yadav 

Can you check if you have a scriptrunner listener that change the value of your field.

Anuradha Yadav
Contributor
January 20, 2021

where do i check that? please help

Kristian Walker _Adaptavist_
Community Champion
January 20, 2021

Hi Anuradha,

I can confirm that you can check Script Listiners inside of your instance at the URL of <JiraCloudBaseURL>/plugins/servlet/ac/com.onresolve.jira.groovy.groovyrunner/script-events-admin?s=com.onresolve.jira.groovy.groovyrunner__script-events-admin

As Mohamed has mentioned it is likely that a script here is configured to change the summary on the issue and this is what is causing the behaviour which you are seeing.

Regards,

Kristian

Anuradha Yadav
Contributor
January 20, 2021

This is the filed group ()use want to change status to none.

7a9f19a4-f338-4a5c-a6ea-df6c45124ffa.jpg

Anuradha Yadav
Contributor
January 20, 2021

I do not have anything in scriptlistener:

image.png

Kristian Walker _Adaptavist_
Community Champion
January 20, 2021

HI Anurdha,

On your screenshot, you are on the enhanced search page and not on the listener's page which is under the site admin pages and you can access using the link I provided earlier or using the steps in the page which Mohamed linked to.

Regards,

Kristian

Mohamed Benziane
Community Champion
January 20, 2021

@Anuradha Yadav

use the link provided by Kristian, and make sure you have the jira-administrator right

Anuradha Yadav
Contributor
January 20, 2021

Hi @Mohamed Benziane @Kristian Walker _Adaptavist_ ,

Sorry i was checking in wrong page.

Now i Got it. As Im just 2 months in groovy. Can u please help me here.? where to see the changes for the group filed?

Below is code I have in Inherit from Epic to Sub tasks on Issue Update:

------------------------------------------------------------------------------------

 

def inherit_nonsingleselect(parent,child,cf) // Inherit for single select drop down custom field
{ def customFieldName = cf as String
def parentreq = get("/rest/api/2/issue/${parent}?fields=${customFieldName}").header('Content-Type', 'application/json').asObject(Map)
def resp = put("/rest/api/2/issue/${child}").header('Content-Type', 'application/json').body([
fields: [
(customFieldName): parentreq.body.fields[customFieldName]
]
]).asString()
}


def inherit_singleselect(parent,child,cf) // Inherit for single select drop down custom field
{ def customFieldName = cf as String
def parentreq = get("/rest/api/2/issue/${parent}?fields=${customFieldName}").header('Content-Type', 'application/json').asObject(Map)
def resp = put("/rest/api/2/issue/${child}").header('Content-Type', 'application/json').body([
fields: [
(customFieldName): [value : parentreq.body.fields[customFieldName]['value']]
]
]).asString()
}

def inherit_valuedriver(parent,child)
{
try{
def customFieldName = 'customfield_10112' //Value Driver
inherit_singleselect(parent,child,customFieldName)
} catch(Exception ex) {}

}


def inherit_Bolero(parent,child)
{
try{
def customFieldName = 'customfield_10091' //Bolero
inherit_nonsingleselect(parent,child,customFieldName)
} catch(Exception ex) {}

}

def inherit_DigitalAimingPoint(parent,child)
{
try{
def customFieldName = 'customfield_10139' //Digital Aiming Point
inherit_nonsingleselect(parent,child,customFieldName)
} catch(Exception ex) {}

}


def inherit_DU(parent,child)
{
try{
def customFieldName = 'customfield_10128' //DU
inherit_nonsingleselect(parent,child,customFieldName)
} catch(Exception ex) {}

}

def inherit_Group(parent,child)
{
try{
def customFieldName = 'customfield_10129' //Group
inherit_nonsingleselect(parent,child,customFieldName)
} catch(Exception ex) {}

}


def inherit_SingleSelect_DU(parent,child)
{
try{
def customFieldName = 'customfield_10126' //DU
inherit_singleselect(parent,child,customFieldName)
} catch(Exception ex) {}

}

def inherit_SingleSelect_Group(parent,child)
{
try{
def customFieldName = 'customfield_10121' //Group
inherit_singleselect(parent,child,customFieldName)
} catch(Exception ex) {}

}

def inherit_Remedy(parent,child)
{
try{
def customFieldName = 'customfield_10069' //Remedy
inherit_nonsingleselect(parent,child,customFieldName)
} catch(Exception ex) {}

}

/*
def inherit_Edison(parent,child)
{
try{
def customFieldName = 'customfield_10114' //Edison
inherit_nonsingleselect(parent,child,customFieldName)
} catch(Exception ex) {}

}*/


def inherit_components(parent,child)
{
try{
def customFieldName = 'components' //components
inherit_nonsingleselect(parent,child,customFieldName)
} catch(Exception ex) {}

}

def inherit_Region(parent,child)
{
try{
def customFieldName = 'customfield_10140' //Region
inherit_nonsingleselect(parent,child,customFieldName)
} catch(Exception ex) {}

}


def inherit_Technology(parent,child)
{
try{
def customFieldName = 'customfield_10122' //Technology
inherit_nonsingleselect(parent,child,customFieldName)
} catch(Exception ex) {}

}

def inherit_SingleSelect_Priority(parent,child)
{
try{
def customFieldName = 'customfield_11671' //Priority
inherit_singleselect(parent,child,customFieldName)
} catch(Exception ex) {}

}


def inherit_PE_Base_Fields(parent,child)
{
try{
def portfolioEpicKeyId = 'customfield_10152' //PortfolioEpicKey
def portfolioEpicSummaryId = 'customfield_10153' //PortfolioEpicSummary
def portfolioEpicStatusId = 'customfield_10154' //PortfolioEpicStatus
def portfolioEpicAssigneeId = 'customfield_10155' //PortfolioEpicAssignee
def portfolioEpicReporterId = 'customfield_10156' //PortfolioEpicReporter

def parentreq = get("/rest/api/2/issue/${parent}").header('Content-Type', 'application/json').asObject(Map)

def resp = put("/rest/api/2/issue/${child}").header('Content-Type', 'application/json').body([
fields: [
(portfolioEpicKeyId): parentreq.body["key"],
(portfolioEpicSummaryId): parentreq.body.fields["summary"],
(portfolioEpicStatusId): parentreq.body.fields["status"]["name"],
//(portfolioEpicAssigneeId): ["accountId":parentreq.body.fields["assignee"]["accountId"]],
(portfolioEpicReporterId): ["accountId":parentreq.body.fields["reporter"]["accountId"]]
]
]).asString()

if (parentreq.body.fields["assignee"]["accountId"] != null){
resp = put("/rest/api/2/issue/${child}").header('Content-Type', 'application/json').body([
fields: [
(portfolioEpicAssigneeId): ["accountId":parentreq.body.fields["assignee"]["accountId"]]
]
]).asString()
}
} catch(Exception ex) {}

}


////////////////////////////////////////////////////////////////
def inherit_StoryFromEpic(story)
{try{

def customFieldName = 'customfield_10008' // Epic link
def epiclink = get("/rest/api/2/issue/${story}?fields=${customFieldName}")
.header('Content-Type', 'application/json')
.asObject(Map)
def epic = epiclink.body.fields[customFieldName]

inherit_valuedriver(epic,story)
inherit_Bolero(epic,story)
inherit_DigitalAimingPoint(epic,story)
inherit_DU(epic,story)
inherit_SingleSelect_DU(epic,story)
inherit_Group(epic,story)
inherit_SingleSelect_Group(epic,story)
inherit_Remedy(epic,story)
//inherit_Edison(epic,story)
inherit_Region(epic,story)
//inherit_components(epic,story)
inherit_SingleSelect_Priority(epic,story)


} catch(Exception ex) {}
}


def inherit_SubtaskFromStory(story)
{try{
def newquery = 'parent =' + story
def newsearchReq = get("/rest/api/2/search").queryString("jql", newquery).queryString("fields", "Flagged").asObject(Map)

Map newsearchResult = newsearchReq.body
newsearchResult.issues.each { Map issue ->
def subtask = issue.key
inherit_components(story,subtask)
inherit_valuedriver(story,subtask)
inherit_Bolero(story,subtask)
inherit_DigitalAimingPoint(story,subtask)
inherit_Region(story,subtask)
inherit_DU(story,subtask)
inherit_Group(story,subtask)

inherit_SingleSelect_DU(story,subtask)
inherit_SingleSelect_Group(story,subtask)

inherit_Remedy(story,subtask)
//inherit_Edison(story,subtask)
inherit_Technology(story,subtask)
inherit_SingleSelect_Priority(story,subtask)


}

} catch(Exception ex) {}
}


def inherit_EpicFromPE(epic)
{
try{
def customFieldName = 'issuelinks'
def result = get("/rest/api/2/issue/${epic}?fields=${customFieldName}").header('Content-Type', 'application/json').asObject(Map)
if (result.body.fields[customFieldName]['outwardIssue']['key'])
{
def list = result.body.fields[customFieldName]['outwardIssue']['key']
for (item in list) {


def result2 = get("/rest/api/2/issue/${item}").header('Content-Type', 'application/json').asObject(Map)
def issuetype = result2.body["fields"]["issuetype"]["name"]
if (issuetype == 'Portfolio Epic')
{
def PE = item
inherit_valuedriver(PE,epic)
//inherit_Bolero(PE,epic)
inherit_DigitalAimingPoint(PE,epic)
inherit_DU(PE,epic)
inherit_Group(PE,epic)

inherit_SingleSelect_DU(PE,epic)
inherit_SingleSelect_Group(PE,epic)

inherit_Remedy(PE,epic)
// inherit_Edison(PE,epic)
inherit_Region(PE,epic)
inherit_PE_Base_Fields(PE,epic)
}

}
}

if (result.body.fields[customFieldName]['inwardIssue']['key'])
{
def list = result.body.fields[customFieldName]['inwardIssue']['key']
for (item in list) {
def result2 = get("/rest/api/2/issue/${item}").header('Content-Type', 'application/json').asObject(Map)
def issuetype = result2.body["fields"]["issuetype"]["name"]
if (issuetype == 'Portfolio Epic')
{
def PE = item
inherit_valuedriver(PE,epic)
//inherit_Bolero(PE,epic)
inherit_DigitalAimingPoint(PE,epic)
inherit_DU(PE,epic)
inherit_Group(PE,epic)
inherit_Remedy(PE,epic)
//inherit_Edison(PE,epic)
inherit_Region(PE,epic)

inherit_SingleSelect_DU(PE,epic)
inherit_SingleSelect_Group(PE,epic)
inherit_PE_Base_Fields(PE,epic)
}

}
}

} catch(Exception ex) {}

}

 

 

def inherit_EpictoStory(epic)
{
try{
def query = '"Epic Link" =' + epic
def searchReq = get("/rest/api/2/search").queryString("jql", query).queryString("fields", "Flagged").asObject(Map)
Map searchResult = searchReq.body

searchResult.issues.each { Map issue ->

def story = issue.key
inherit_valuedriver(epic,story)
inherit_Bolero(epic,story)
inherit_DigitalAimingPoint(epic,story)
inherit_DU(epic,story)
inherit_Group(epic,story)
inherit_Remedy(epic,story)
//inherit_Edison(epic,story)
inherit_Region(epic,story)
//inherit_components(epic,story)
inherit_SingleSelect_DU(epic,story)
inherit_SingleSelect_Group(epic,story)
inherit_SingleSelect_Priority(epic,story)

inherit_SubtaskFromStory(story)

}

} catch(Exception ex) {}
}


def DemandUnit_to_Group(pe)
{
try{
sleep(3000)
// def issueKey = pe
// def customFieldName = 'customfield_10128' //DU
// def customFieldName2 = 'customfield_10129' // Group
// def result = get("/rest/api/2/issue/${issueKey}?fields=${customFieldName}").header('Content-Type', 'application/json').asObject(Map)


// def list = result.body.fields[customFieldName]['value']
// def strR = ''


// def a = [['GS','DORC'],['DNP','DNP ANH'], ['DNP','DNP HNH'], ['DNP','DNP PCA'],['GS','DMSC'],['GS','DS&T'],['GS','FEF'],['GS','FES'],['GS','FEP&O'],['GS','FSS'],['GS','GIS'],['GS','HQ'],['GS','HRSS'],['GS','PSS'],['GS','TS'],['MIF','DAM'],['MIF','DBM'],['MIF','DEP'],['MIF','DFS'],['MIF','DIC'],['MIF','DRF'],['MIF','DYN'],['MIF','NIAGA'],['GS','GBS'],['GS','GTx (Group Taxation)'],['GS','GTr (Group Treasury)'],['GS','GA (Group Accounting)']]


// for (item in list) {
//strR = strR + item
// for (i2 in a)
// {
// if (item == i2[1])
// {strR =strR + "['value': '" + i2[0] + "'],"}
// }
// }


//strR = Eval.me('[["value": "MIF"],["value": "DNP"],["value": "GS"]]');
// strR = Eval.me('[' + strR + ']');
// def strf = [fields: [(customFieldName2):strR]]
// def resp = put("/rest/api/2/issue/${issueKey}").header('Content-Type', 'application/json').body(strf).asString()

def issueKey = pe
def customFieldName = 'customfield_10126' //DU
def customFieldName2 = 'customfield_10121' // Group
def result = get("/rest/api/2/issue/${issueKey}?fields=${customFieldName}").header('Content-Type', 'application/json').asObject(Map)


def list = result.body.fields[customFieldName]['value']
def strR = ''

def a = [['GS','DORC'],['DNP','DNP'],['DNP','DNP ANH'], ['DNP','DNP HNH'], ['DNP','DNP PCA'],['GS','DMSC'],['GS','DS&T'],['GS','FEF'],['GS','FES'],['GS','FEP&O'],['GS','FSS'],['GS','GIS'],['GS','HQ'],['GS','HRSS'],['GS','PSS'],['GS','TS'],['MIF','DAM'],['MIF','DBM'],['MIF','DEP'],['MIF','DFS'],['MIF','DIC'],['MIF','DRF'],['MIF','DYN'],['MIF','NIAGA'],['GS','GBS'],['GS','GTx (Group Taxation)'],['GS','GTr (Group Treasury)'],['GS','GA (Group Accounting)'],['GS','GS (Group Sourcing)'],['GS','FR (Finance Regions)']]


for (i2 in a)
{
if (list == i2[1])
{strR = i2[0]}
}


def cfg = 'customfield_10121'

def resp = put("/rest/api/2/issue/${issueKey}").header('Content-Type', 'application/json').body([
fields: [
(cfg): [value : strR]
]
]).asString()






} catch(Exception ex) {}
}

def start_inherit_story(story)
{
// If story then copy from Epic
inherit_StoryFromEpic(story)
// If story then Send to sub tasks
inherit_SubtaskFromStory(story)

}

def start_inherit_Epic(epic)
{
//Copy values from PE
inherit_EpicFromPE(epic)
//Inherit to Story and subtasks
inherit_EpictoStory(epic)

}

def start_inherit_PortfolioEpic(PE)
{

try {
def customFieldName = 'issuelinks'
def result = get("/rest/api/2/issue/${PE}?fields=${customFieldName}").header('Content-Type', 'application/json').asObject(Map)
if (result.body.fields[customFieldName]['inwardIssue']['key'] )
{
def list = result.body.fields[customFieldName]['inwardIssue']['key']
for (item in list) {
def epic = item
start_inherit_Epic(epic)
//inherit_EpictoStory(epic)
}
}
if (result.body.fields[customFieldName]['outwardIssue']['key'] )
{
def list = result.body.fields[customFieldName]['outwardIssue']['key']
for (item in list) {
def epic = item
start_inherit_Epic(epic)
//inherit_EpictoStory(epic)
}
}


} catch(Exception ex) {}

}

def inheritEstimateToEpic(estimateid){
try{
def customFieldName = 'issuelinks'
def capabilityToPlanFieldId = 'customfield_10149'
def result = get("/rest/api/2/issue/${estimateid}?fields=${customFieldName}").header('Content-Type', 'application/json').asObject(Map)

if (result.body.fields[customFieldName]['outwardIssue']['key'])
{
def list = result.body.fields[customFieldName]['outwardIssue']['key']
for (item in list) {


def result2 = get("/rest/api/2/issue/${item}").header('Content-Type', 'application/json').asObject(Map)
def issuetype = result2.body["fields"]["issuetype"]["name"]
if (issuetype == 'Epic')
{
def epicIssueId = item
def parentreq = get("/rest/api/2/issue/${estimateid}?fields=${capabilityToPlanFieldId}").header('Content-Type', 'application/json').asObject(Map)

def resp = put("/rest/api/2/issue/${epicIssueId}").header('Content-Type', 'application/json').body([
fields: [
(capabilityToPlanFieldId): [value : parentreq.body.fields[capabilityToPlanFieldId]['value']]
]
]).asString()

}

}
}

if (result.body.fields[customFieldName]['inwardIssue']['key'])
{
def list = result.body.fields[customFieldName]['inwardIssue']['key']
for (item in list) {
def result2 = get("/rest/api/2/issue/${item}").header('Content-Type', 'application/json').asObject(Map)
def issuetype = result2.body["fields"]["issuetype"]["name"]
if (issuetype == 'Epic')
{
def epicIssueId = item
def parentreq = get("/rest/api/2/issue/${estimateid}?fields=${capabilityToPlanFieldId}").header('Content-Type', 'application/json').asObject(Map)

def resp = put("/rest/api/2/issue/${epicIssueId}").header('Content-Type', 'application/json').body([
fields: [
(capabilityToPlanFieldId): [value : parentreq.body.fields[capabilityToPlanFieldId]['value']]
]
]).asString()

}

}
}


} catch(Exception ex) {}
}

 

////////////////////////////////////////////////////////////////
try{

def issueKeytemp = issue.key
def result = get("/rest/api/2/issue/${issueKeytemp}").header('Content-Type', 'application/json').asObject(Map)
def issuetype = result.body["fields"]["issuetype"]["name"]
if (issuetype == 'Story' || issuetype == 'Bug' || issuetype == 'Design Story' || issuetype == 'Service Request')
{
start_inherit_story(issueKeytemp)
}

if (issuetype == 'Sub-task' || issuetype == 'Incident' || issuetype == 'Estimate')
{
def story = result.body["fields"]["parent"]["key"]
inherit_SubtaskFromStory(story)

}

if (issuetype == 'Epic')
{
start_inherit_Epic(issueKeytemp)
}


if (issuetype == 'Portfolio Epic')
{
DemandUnit_to_Group(issueKeytemp)
start_inherit_PortfolioEpic(issueKeytemp)
}

if(issuetype == 'Estimate'){
inheritEstimateToEpic(issue.key)
}

}catch(Exception ex)
{

}

Anuradha Yadav
Contributor
January 20, 2021

Just need to understand "I need to understand why I am not able to change the value of this field to None"

Kristian Walker _Adaptavist_
Community Champion
January 20, 2021

Hi Anurdaha,

Can you please confirm what type is the field you are trying to set to None and

If it is the status field you are trying to change, you cannot change the value of this field to *None* as Jira does not allow this and requires to change status you must transition an issue and you can only transition to an issue that the workflow has a transition to from the issues current status?

Regards,

Kristian

Anuradha Yadav
Contributor
January 20, 2021

Hi @Kristian Walker _Adaptavist_ ,

No It is a custom field.

 

Regards,

Anuradha

Kristian Walker _Adaptavist_
Community Champion
January 20, 2021

Hi Anurdha,

Can you please confirm what type is the custom field as without knowing what type then I cannot advise how to clear its value in your script.

Regards,

Kristian

Anuradha Yadav
Contributor
January 20, 2021

Hi, I see its a multifield selector.

does it help?

image.png

Kristian Walker _Adaptavist_
Community Champion
January 20, 2021

Hi Anuradha

Can you send go to the page at <JiraCloudBaseURL>/secure/admin/ViewCustomFields.jspa from before you click on the field and to confirm what type it says the field is in the Type column as I will need to know this type in order to advise further as your screenshot does not show the type of the field.

Regards,

Kristian

Anuradha Yadav
Contributor
January 20, 2021

Hi @Kristian Walker _Adaptavist_ ,

Please find the snip.

image.png

Anuradha Yadav
Contributor
January 20, 2021

image.png

Anuradha Yadav
Contributor
January 20, 2021

In the above Snip user wants to change status of group filed to none. But the script runner is now allowing

Anuradha Yadav
Contributor
January 20, 2021

image.png

this will help?

0 votes
Kristian Walker _Adaptavist_
Community Champion
January 21, 2021

Hi Anurdhava,

Thank you for your response.

This indicates the field is a Single Select List field.

From the field, I can confirm it does not have an option configured called None so you cannot configure this to have a value of None unless you

However, if you want to clear the field so it has no value set then you can do this by setting the field value to null In your script to Null.

I can confirm we have an example script located here which shows how to clear values of different field types when cloning an issue and this script can be used as a reference guide to show how you can clear the field value for your Single Select List field named Group.

I hope this information helps.

Regards,

Kristian

Anuradha Yadav
Contributor
January 21, 2021

Hi @Kristian Walker _Adaptavist_ ,

I see below options..

MIF

DNP

GS

None

So where to check why its not changing to None option.

 

image.png

Anuradha Yadav
Contributor
January 21, 2021

also default value is set as none as i see below:

 

image.png

Kristian Walker _Adaptavist_
Community Champion
January 21, 2021

Hi Andurdaham,

The None option was to shown in your last screenshot.

In order to set the value, you will need to use the syntax similar to shown in the example located here which can be run on the script console to show how to set an option value in a select list field.

You will be able to take the rest call here and use this as a reference guide to make a rest call in your script code to set the value of your field to none.

Please note that the examples I have provided have been tested and show how to set a field value and you will be able to use these to help refactor your script.

Please, note I can refactor your script for you and the examples I have given show how to achieve your requirement, so you will need to take these and use these to help debug and refactor your script to achieve your requirements.

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer