Forums

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

Field 'customfield_10406' cannot be set. It is not on the appropriate screen, or unknown

Asha Kumari
September 19, 2018

I am using the Scriptrunner listener capability of Jira cloud version to update a field called 'Urgency' based on the value of the field 'Severity'. This is for a servicedesk project.

I checked the screens (actually there is only 1 screen for create, view, edit) and the screen has both of these fields. Yet, I am not able to update the field value and it keeps giving me the above error. I am running the script as a "ScriptRunner Add-On User"

Could someone please help me to point out where the problem is and how can I address this?

Roughly, this is how my script looks:

def projectKey = "PS"

def issueKey = issue.key
def issueType = ((Map)issue.fields.issuetype).name as String

if (issueType == null || issueType != "Bug") {
logger.info("Wrong Issue Type ${issueType}")
return
}

def fields = issue.fields as Map
def severityField = get("/rest/api/2/field")
.asObject(List)
.body
.find {
(it as Map).name == 'Severity'
} as Map

def severityValue = (fields[severityField.id] as Map).value as String
def urgencyValue = "" as String


if (severityValue == "A" || severityValue == "B") {
urgencyValue = "Critical"
} else if (severityValue == "C") {
urgencyValue = "High"
} else if (severityValue == "D") {
urgencyValue = "Medium"
} else {
urgencyValue = "Low"
}


def urgencyField = get("/rest/api/2/field")
.asObject(List)
.body
.find {
(it as Map).name == 'Urgency'
} as Map

def result = put("/rest/api/2/issue/${issueKey}")
.queryString("overrideScreenSecurity", Boolean.TRUE)
.header('Content-Type', 'application/json')
.body([
fields: [
"{$urgencyField.key}": [
value: "${urgencyValue}"
]
]
])
.asString()

if (result.status == 204) {
return 'Success'
} else {
return "${result.status}: ${result.body}"
}


 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
July 22, 2022

You can't completely change the permissions other than with the "Edit Issue Permissions" in the permission scheme.

I understand that the permission scheme can't be configured to be conditional. It is all or nothing.

The closest you can come to your requirement is with:

https://docs.adaptavist.com/sr4js/latest/features/script-fragments/built-in-fragments/hide-ui-element-built-in-script

But the user will still have permission to use the in-line edit option and would still have permission to edit the issue with the REST API or any plugin that offers issue editing functionality.

Another approach you could try is to use behaviours to make all your fields read-only when your condition is true. This way, the user will see and be able to click the edit button, but won't be able to change any values.

James Lebron
Contributor
July 24, 2022

Thank u.
Thanks for giving me this idea, I'm trying to figure it out.

TAGS
AUG Leaders

Atlassian Community Events