I am trying to use ScriptRunner behaviors to set up a default description based on the selected component. I have configured the Behavior and associated it to a Project and Issue Type.
Initially I was using the Initializer as in the example, but that sets a Default Description before the Component is set.
So I moved my script to the Component field, assuming that when I select a Component, the description will update. That is NOT what is happening. The script doesn't appear to run when the component field is changed.
Is this possible? (on the Create Issue screen, having the Description update based on the Component selection)
If possible, is this the correct way to accomplish?
If possible, how does this script look to you?
Thank you, Leo. You got me closer by realizing I needed to get the field value not the underlying issue value.
Also, from another source after much searching, I figured out how to get the first component! This was the key, defining the value returned from component as a List. Then I could reference the first one on the list!
def componentField = getFieldById(getFieldChanged());
def components = componentField.getValue() as List<ProjectComponent>
def comp = components.first().name;
I believe the script does run but it sets description to default value always
if so, that is due to your comparison method, you are using "comp" variable in which stored component/s of the current issue(usually returns from DB value) but that's not having any value yet
rather you should use "comps" variable and get first value from list and do the comparison
hope this helps
I am not that familiar with this programming language but I can't seem to access the first element of the array doing this:
def componentField = getFieldById("components");
def comps = componentField.getValue();
//get the values of the component field
def comp = comps.getName();
//to try to get the name of the first element
It doesn't allow me to reference the first element of comps.
Hi @Shannon Davis I hope I can help you.
Are you sure the script is not executed at all? Did you try to add some logging to it? I suggest you to add following code to 2nd row
log.error("executing behaviours with default description")
Then you can check your server log file to find out whether it is executed or not.
Did it work for you when you added it to initializer? Based on your code, "Background Justification:" should be added to description field even without picked up component.
Hi Atlassian Community, My name is Avni Barman, and I am a Product Manager on the Confluence Cloud team. Based on feedback from you, we are giving admins more power to create templates that a...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events