Forums

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

scriptrunner question

Alex Ivanov August 22, 2023

Hello, im using scriptrunner for restriction of customfield change by users that isnt members of jira-administrators group, on existing tickets it works fine, but now im trying to do it for new tickets, i dont know how to setup correct value of customfield, im getting error: 

body: {"errorMessages":[],"errors":{"customfield_10157":"Specify a valid 'id' or 'name' for Internal Severity","customfield_10158":"Specify a valid 'id' or 'name' for External Severity"}}

image.pngwhat should i use as customfield value? or maybe im doing another mistake?

by api request im getting this values of this fields that i should use: 

 from:10676, fromString:None (0) tried to use both, but still no effect.

4 answers

1 accepted

1 vote
Answer accepted
Joaquin Fernández Morales
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 Leaders.
August 23, 2023

Hi again, 

 

I think you should use the External Severity value , I mean,  Trivial (1), Low (2) ..... For example, I checked with a cf called "Severity" which has two possible values ,  ONE or TWO.  Check my screenshots for clarifying it. 

 

 

CODE.pngSEVERITY.png

 

 

 

I hope it helps. 

Alex Ivanov August 24, 2023

Thanks, this format works!

2 votes
Joaquin Fernández Morales
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 Leaders.
August 23, 2023

Hi Alex, 

I can see some possible issues in your code: 

 

  • The name of the group ends with two "s" , jira-administratorss ., which seems to be a spelt error. 
  • Probably the condition will aways be false of:  "boolean isCreation = !changelog" . Could you check the value of this variable writing a logger.info(isCreation.toString()) after the previous assignation. If this condition doesn't work, could you override it by checking if field 10157 has a value or is null ?
  • You are setting twice the same custom field with the same value. 
  • Is the string "106710" a valid value for the custom field 10157?
  • Is the custom field 10157 a select list custom field . If so,  then It seems that the field type you are using failed to match the format you are inserting too and you should use the syntax:

       fields: [
                (customField.id):[value: "<OptionValueHere>"] as Map
        ] 

 

In addition, to get what you want, this way is not ideal, and you could avoid having to perform these checks and conditions to see if the issue is being created or already exists by simply using two script listeners, one for the "issue created" event and another for the "issue updated" event. 

I leave the documentation about the script listeners here: https://docs.adaptavist.com/sr4jc/latest/features/script-listeners

 

I hope it helps. 

Alex Ivanov August 23, 2023

Thanks for answer!

I know about group name and same id for customfields, already fixed it. 

But for this error:

body: {"errorMessages":[],"errors":{"customfield_10157":"Specify a valid 'id' or 'name' for Internal Severity","customfield_10158":"Specify a valid 'id' or 'name' for External Severity"}}

 still same, im using your example right? 

def resp1 = put("/rest/api/3/issue/${issue.key}")
.header('Content-Type', 'application/json')
.body([
fields: [
(customfield_10157):[value: 10676] as Map
]
])
.asString()

this customfield is dropdown list of fixed values: i checked available values by api request and found 2 usefull id for needed default value: 

 from:10676, fromString:None (0)

 

image.png

0 votes
Mogees Hassan
Banned
July 15, 2024

o schedule a lash lift appointment in Winston-Salem using ScriptRunner, you can automate booking processes by running a script that interacts with the salon's online booking system, ensuring efficient and accurate scheduling.

0 votes
arslan arslan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 26, 2023

In your Jira automation using Scriptrunner, ensure the accuracy of custom field IDs or try specifying custom field values using their names. For example, use field names like "Internal Severity" and "External Severity" instead of numeric IDs. Confirm that these custom fields are available in the field configuration associated with the project or issue type you are working with. Verify the field context to ensure they are applicable to the desired project and issue type. If the issue persists, consult the Jira REST API and Scriptrunner documentation for any specific requirements or considerations. It's advisable to test changes in a safe environment before applying them to a production instance. If additional information about your configuration is provided, more targeted assistance can be offered.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events