Set field description using behaviour

Mohammed Siyad
Contributor
October 14, 2024

Hi team,

I am trying to set a field description using behaviour for JIRA. I was able to achieve that but the problem is that there is duplication of the description 2 times and i think it is because there is already a field description set by field configuration scheme.

 

I cannot change what is present in field config because it impacts multiple projects as well multiple issutypes. Can we remove the multi- description via behaviour and override those.

Members1.pngMembers2.png

 

Code i used:-

 

 

def members = getFieldByName('Members')
members.setDescription('<h4><span style="color: blue;">Requestor Email</span></h4>').setRequired(true)

1 answer

0 votes
Radek Dostál
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.
October 15, 2024

FormField#setDescription() does exactly as the same name suggests - it sets the description, it doesn't append it. Anything you have in field configuration gets overwritten. Unless for whatever reason someone created new html elements from it with javascript or something.

 

If there already is the same description, why trying to add it again?

 

Additionally I'd be curious to see what you're getting in response to the '/rest/scriptrunner/behaviours/latest/validatorsByPid.json' endpoint. Whenever you are creating or editing an issue, an ajax request gets POSTed there, and the response contains a json with behaviour stuff. This should include the field and it's description - just want to see if there it is once, or twice.

 

Either way, even if you had conflicting behaviours, or field configurations, only the last setDescription invocation will win. I think you have either a custom html block that doesn't "act" as a description (thus the behaviour cannot overwrite it), or something else buggy going on but we would see from the REST endpoint what's coming in.

Mohammed Siyad
Contributor
October 16, 2024

I dont properly follow on this. There is no behaviour apart from this. So basically what happens is that :-

1. Custom field Members has got a description set already on a global level as "Multi-User picker field intended to help identify useful resources who can inform, advise, review, or help progress the issue."

2. "Start typing to get a list of possible matches." by default it is present for many fields.

 

So when I write a behaviour to overwrite this, it overwrites 2 times.

 

Mohammed Siyad
Contributor
October 16, 2024

I did a workaround by removing the description by passing setDescription as empty and then setting the helptext using the html

Suggest an answer

Log in or Sign up to answer