Hello, I want a script listener to run when a form is submitted (rather than an issue is created). However I can find that type in the 'On these events'.
I therefore tried to run a post function on a workflow transition which would give me the same trigger. In the condition field I need to condition it further. However for a post function it is not as easy to make a condition like it is in a Script listener as you don't have the expression builder and that type of language.
If I make the condition in the expression builder and then paste it to a post function it isn't accepted.
Therefore I guess I have two questions:
1. Is there a way to set up a 'on these events' in a script listener that is the equivalent of a 'form submitted' so I don't have to use a post function
2. If not how do I write the below expression that will be accepted in the post function expression?
issue.customfield_14407 ?
Hi @George Davies ,
I am unsure which action in Jira you are referring to when you say "Form Submitted", but unfortunately, if the event you need is not currently listed in Event Listeners there is no way to add a new one there.
In regards to your second question, your expression is checking to see if either "Customers" or "Vendors" are present in Custom Field 11407, the field is a single select, and you want to return true if the value is either one of them, correct?
In which case, you can use:
return issue.fields.customfield_14407.value in ['Customers', 'Vendors']
Could you give that a go and let me know how you get on?
Kind regards,
Bobby
Hi Bobby,
As for question one. Certain issue types follow an approval workflow. Initially when a ticket is created it has to wait for an approval before it can be worked on. During the approval step extra information is added and once approved the 'form is submitted' for an automation to occur (well this at least is a trigger with this in Jira automation) Obviously I want to mirror this in Script runner for Jira, Script Listener.
As for the second case and performing it as a post-function in the relevant workflow. I am only wanting the post function to perform if the field 14407 has the value 'Customers' or 'Vendors'.
The example you provided returns an error. '
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ahh, I am not 100% what you are referring to, but I will confess to not knowing the depths of Jira.
If you could, could you take a screenshot of the trigger you are referring to in Automation? That might help me.
In regards to your error, its not an error as much as a warning. In short, in Groovy you can define a value as a "Map", which is a collection of key-value pairs, for example, with the following Json:
{
value1: "hello"
value2 : "world"
value3 : {
subValue1 : "Sub Hello"
subValue2" "Sub World"
}
{
If we define this value as a Map, it will handle value1 and value2 fine, but struggle if we try to get value3.subvalue1, because this is a key-value list inside a key-value list, and we didn't tell Groovy that value3 was also a Map, so its not evaluating it correctly.
So, when we go down a level, we need to let it know we are dealing with another Map. So we would end up with:
def mainValue = value as Map
def subValues = value.value3 as Map
def subval2 = subValues.subValue2
When you consider a Jira Issue value that is returned from a REST API (I imagine you know, as you ran it through the script console, you have probably ran the entire issue) its structure is JSON objects inside JSON objects inside JSON objects. So, we need to define each level as a Map to help Groovy understand what we are dealing with.
All of that to say, the condition should still work, but if you would like to remove the errors it would look something more like this:
def issueFields = issue.fields as Map
def customfieldSelectList = issueFields.customfield_14407 as Map
return customfieldSelectList.value in ['A', 'H']
Could you try this and let me know? Also, let me know if my explanation helped or if anything was unclear!
Kind regards,
Bobby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ideal Bobby, That's better good to know that not every red error will fault the script. I guess I am afraid that all of our companies admins will get an error when something goes wrong so I try to clear them.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Makes sense! Always good to get rid of them if you can, even if it turns a 1 line script into 3, to be honest!
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.