Save a system field value in a constant

Originally asked by Andrey Miranda on 28 June 2020 (original question)


i have two project in Jira cloud for example Project SD and Project IT .

and i need to call a transition when the replica status== Done and replica.resolution== wrong project

in the project HD.

the info about replicas are of the project IT

i try it creating a mapping status but i have some error and i think if is possible the next solution:

example:

outgoing sync

Issue.status=Replica.status

incoming sync:

I think if possible to save the status in the constant (Status)

def Status = nodeHelper.getStatus(replica.status?.name)

if ( Status== "Done") {
   if ( replica.resolution.name == "Wrong Project") {
      workflowHelper.transition (issue, "De-Escalate Issue (Auto)")
   }

else 
   if ( replica.resolution.name != "Wrong Project") {
      workflowHelper.transition (issue, "Resolve Issue (Auto)")
   }
}

all the script dont have error but no call the transition
i’m not sure if is ok when i save the status in the constant

if you have some idea o suggestion tell me?

Thanks


Comments:

Francis Martens (Exalate) commented on 10 July 2020

I changed the layout a bit for readability

Answer by Francis Martens (Exalate) on 10 July 2020

The reason why there is no transition is because the getStatus is a status object and not the name of the status

If you adapt the code to

def status = nodeHelper.getStatus(replica.status?.name)

if (status?.name == "Done") 
...

It will work.

Note also that you might as well do

if (replica.status?.name == "Done") 
...

Because the name of the status returned by getStatus is the same


Comments:

Andrey Miranda commented on 13 July 2020

thanks for the solution

Francis Martens (Exalate) commented on 14 July 2020

You’re welcom Andrey Miranda - can you accept the answer?