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)
}
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is a closed list of fields that work with UI Modification API:
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.