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.
April 30, 2021

Sure... simple enough...

User a simple scripted validator with this script:

def today = new Date()
today.day != 5 || cfValues['Target Date'] > today.clearTime() + 4

This will be true if either:

  • today is not a Friday
  • the target date is later than 00:00am on the 4th day after today

When the validator is true, the transition is allowed.

When the validator is false (both conditions above are false at the same time), then you specify the error message to display on the Target Date field

2021-04-30 10_29_19-Add Workflow Function Parameters.png

Lars Schirmer
May 3, 2021

Hey Peter,

I tried your script but it doesn't work for me. I think I need to be more specific and my usecase changed a bit...

 

Target date must be apart 2 days from created date (example: created date = monday than target date can't be either the same day nor the next day). Additionally, if created date is a friday target date must at least the next tuesday.

 

thanks in advance :)

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.
May 3, 2021

Then my guess is that if Created Date is a Thursday then the target date must be the next Monday?

If so, that's how I would do it:

def today = new Date()
def minDate = today.clearTime() +2
if(today.day in [4,5,6]){
//on thursday, friday or saturday add 2 days to account for the weekend
minDate = minDate+2
}
cfValues['Target Date'] > minDate
TAGS
AUG Leaders

Atlassian Community Events