Hello Community,
in Jira Automation I changed the Summary by concatenating two other issue field values as you see in the following figure.
Now I want to achieve the same result using Script Runner. Therefore I am trying to set an Behaviour, which fail. In the following figure I show you my script. Maybe I also have to use a listener instead but first of all I want to understand the basic script structure :)
Hi there, your script looks like it should work but can I just check what the 2 fields are? I'm presuming these are custom fields, so you might need to use this instead -
def maxToleranceDateCustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName("Max Tolerance Date")
def maxTolerancedatestartingvalue = underlyingIssue?.getCustomFieldValue(maxToleranceDateCustomField)
something along those lines, obviously change my field name for your field names.
Also if the fields are on the form you can use
def CFFieldVal = getFieldByName("Insert Custom Field Name").getFormValue()
Thank you Will C for your support! I really appreciate that!!!
I changed my script using yours and I think we are way closer to the target. but some errors still remain.
as you see I did some imports, because I thought these would solve the problem. BTW do I have to always do some imports when I am using functions like this?
Then I believe the "-" character causes the last problem. In my automation rule from above I also used this as a seperator. The aim is to create summarys like "KDT-002". I dont want to subtract one from another. How am I supposed to code that? (BTW how would I do this if I literally would want to subtract, add or multiply fields with another?)
And lastly, could you please explain what you mean with "Also if the fields are on the form you can use". So what form do you mean?
Already best thanks to you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are multiple ways to achieve the string you want :
(Customfield1 + "-" + customfield2)
("${customfield1}-${customfield2}")
if you wanted to subtract one from another I'm guessing they are both integers you can do just customfield1 - customfield2.
so using getFormValue() gets the value of that field on the form at that time, whereas underlying issue will get the value that is already saved to the issue.
I hope that all helps?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Best thanks to you, I have finally no errors in this script :)
To achieve the string I tried both variants - but only the second one did work. In the figure below you see the error message I get using the first way.
Also I needed to change the "ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(xxx)"-method in "ComponentAccessor.getCustomFieldManager().getCustomFieldObject(xxx)", to made this work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That error is just static type checking and can be ignored in scriptrunner
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alright :)
Do you know whether I am correct with using a Behaviour? Or do I have to use a Listener or whatsoever? Because I dont know how I can adjust, that this behaviour will be executed every time an issue of an specific issuetype is created or updated
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In my Jira Automation Rule I defined that the Rule is triggered when an Issue (specific issuetype) is created or updated. I also want this in my ScriptRunner Behaviour. I guess I have to write it in the initialiser section. But I dont know what. Could you help me out?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.