how to use setError() to IssueType system field?

achal khawale May 21, 2021

Hello ,

M using Scriptrunner Behaviors.

I tried adding a error msg using setError() function to issueType system field it is not working.

options i tried :

getFieldById("issuetype").setError("Error Msg")

/////////

import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE

getFieldById(ISSUE_TYPE).setError("Error Msg")

//

i trried getFieldChanged() also still no luck.

for the same readonly and required is working perfecly fine.

 

Please help

2 answers

0 votes
Max Lim _Adaptavist_
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.
May 23, 2021

I have tried:

getFieldById("issuetype").setError("Error Message.")
getFieldById(getFieldChanged()).setError("Error Message.")

They both work. It might be a bug, you might want to upgrade your ScriptRunner.

0 votes
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 21, 2021

@achal khawale Are you trying to set description for Issue Type field or when user select XXX issue type they get error message ?

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.*


def issuetype = getIssueContext().getIssueType().name


if (issuetype.contains("Bug")) {
getFieldById("issuetype")
.setDescription("<font size=\"2f\">This Issue type not in Use</font>")

}
else if (issuetype.contains("Android")) {
getFieldById("issuetype")
.setDescription("<font size=\"2f\"> Testing releated issues <font color=\"red\">Rush requests require Team Lead sign-off</font>")
achal khawale May 21, 2021

setDescription works but no the error. i want to stop user from submitting the form

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 22, 2021

Hi @achal khawale if you want to stop creating issue under issue type then hide the issue type from the list or remove from issue type scheme.

Suggest an answer

Log in or Sign up to answer