Forums

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

Scriptrunner for Jira Cloud Not making comment and linked issue field mandatory

Vikrant Yadav
Community Champion
June 24, 2025

Hi Experts,

I am trying to make a Linked Issue and Comment field mandatory on a transition screen via Behavious. But the below script is not working on transition screen. 

Kindly help me in fixing the code. 

Error message on transition scree : 

We couldn't load the UI modifications for this form.
const transitionId = await getContext().then(context => context.extension.issueTransition.id); 
const linkedIssue = getFieldById("issuelinks")
const commentField = getFieldById("comment")
if (transitionId == 21) {
linkedIssue.setRequired(true)
commentField.setRequired(true)
}

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
3 votes
Answer accepted
Evgenii
Community Champion
June 24, 2025

Hi, @Vikrant Yadav 

You can instead add SR validator, to check for comment


issue.comments.some(comment => comment.id == null)

 If you want to use behaviours only, you can open browser console, and try to make transition.
There you'll see error, why behaviour is not working. I usually use this method, when behaviour is not working.

Vikrant Yadav
Community Champion
June 24, 2025

I want to give a customized error message also. 

Validator does not offer this feature. 

I have used validator for linked issue as well, but it's not showing customized message , user won't be able to identify the reason why getting this error message and for which field. 

With the help of behaviour i want to set helptext, if possible ? 

Default message : 

A ScriptRunner Script Validator is preventing this transition, please contact your Jira admin for more information.

 

Evgenii
Community Champion
June 24, 2025

@Vikrant Yadav sure, you can add custom help text with SR validator.
There are 3 fields in validator:
- Name
- Validation failed message
- SR expression

Enter required text in Validation failed message and it will be shown on transition screen.

Screenshot_43.png

Like Vikrant Yadav likes this
Vikrant Yadav
Community Champion
June 24, 2025

Thanks @Evgenii  Yep in my system also I have this option set validation failed message. 

This works for my use case. Thanks a lot @Evgenii  

Is it possible to check via jira expresion that linked issues should of ABC project and link type "is blocked by" ?

Link type is am able to validate but not sure about project. Can you please cofirm. 

Vikrant Yadav
Community Champion
June 24, 2025

I am using this validator right now : 


issue.links
.filter(l => l.type.inward == 'is blocked by' || l.type.inward == 'is cloned by')
.length > 0
Evgenii
Community Champion
June 24, 2025

You need something like this, I think:

issue.links
    .filter(link => link.type.inward == 'is blocked by')
    .every(link => link.linkedIssue.project.key == 'ABC')

or

issue.links
    .filter(l => l.type.inward == 'is blocked by')
    .some(l => l.linkedIssue.project.key == 'ABC')

First variant If you want all issues to belong to ABC project, second - for at least one.

Or, your slightly modified query:

issue.links
    .filter(l => l.linkedIssue.project.key == 'ABC' && (l.type.inward == 'is blocked by' || l.type.inward == 'is cloned by'))
    .length > 0
Like Vikrant Yadav likes this
Vikrant Yadav
Community Champion
June 24, 2025

Thanks @Evgenii 

Like Evgenii likes this
2 votes
Maciej Dudziak _Forgappify_
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.
June 24, 2025

Hi @Vikrant Yadav 

There is a closed list of fields that work with UI Modification API: 

https://developer.atlassian.com/platform/forge/apis-reference/jira-api-bridge/uiModifications/#issue-view--preview-

Comments and Linked issues is not supported yet. A Jira expression-based validator would be the way to go. There are couple of options on the martkeplace

Cheers

 

 

 

Vikrant Yadav
Community Champion
June 24, 2025

Thanks @Maciej Dudziak _Forgappify_  for sharing the supported field list. 

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events