I have an issue that is automatically created in JSM by another tool. This issue always contains a string like this:
Ambiente: XPTO
Serviços: ServiceA, ServiceB, ServiceC
Emissores impactados: XYZ, KUO, BMN
The list of "Serviços" is variable. There can be at least one. The name of de services listed in this field is the same as the name of Services assets.
I created an automation that is supposed to "convert" this string of services and set each one in "Affected Services" field.
So, the first thing I did was to create a branch to iterate each service:
It worked. The result of the action above is an array:
[Service A]
[Service B]
[Service C]
Then, I looked up the object in the Assets:
It also worked.
And then, last I updated the Affected Services field adding the object loaded before:
This is the code above:
{
"update": {
"Affected services" :
[{"set":[
{{#lookupObjects}}
{"id":"{{Service ID}}"}
{{^last}}, {{/}}
{{/}}
]
}]
}
}
I found the information above in Atlassian community.
Problem: It seems that the update bellow runs only once, even with the iteration running. I know that the iteration runs asynchronously and I don´t mind the order of the services to be included. But, only one service is included in my list.
I put some logs in the automation, and there are the results:
And here is the issue that was used in the automation above:
As you can see, only one of the three services is included in the list of "Affected Services". In this case, it was the first one, but I tried it so many times and the behaviour is random (sometimes the second, sometimes the last service).
Based on the logs, my assumption is that the "Edit Field" step is running only once. Does anyone knows an alternative to this problem?
This was the solution provided by Atlassian Support:
Findings
As you are using a branch to edit the same issue, the values are being set in a race condition. You must add them at once.
Next steps
Remove the branch (keeping its actions), and update the AQL on your lookup action as follows:
Name in ({{issue.description.substringBetween("Serviços: ","Emissores").split(",").trim()}})
This was the solution provided by Atlassian support:
Findings
As you are using a branch to edit the same issue, the values are being set in a race condition. You must add them at once.
Next steps
Remove the branch (keeping its actions), and update the AQL on your lookup action as follows:
Name in ({{issue.description.substringBetween("Serviços: ","Emissores").split(",").trim()}})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Renatão
First thing, I am not using JSM with assets and so cannot test my suggestions.
Your advanced edit with JSON is using a set operation, inside of the iterator on your Services. And so it is possible the objects are getting repeated replaced, and the last one "wins".
Have you instead tried using an add operation for "Affected services" in the JSON?
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
Yes, I tried. But the following error was found:
(Field with id' customfield_10034' and name 'Affected services' does not support operation 'add' Supported operation(s) are: 'set')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is unfortunate...and will instead require performing one single update to add all of the services at one time.
Can the services be added by name rather than id value? If so, instead of using the advanced branch over the services, an iterator could be used to create a single JSON expression to add them at one time...or perhaps even edit without the JSON using the field drop-down list for Affected Services and a smart value list.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is unfortunate, and this seems more challenging to solve.
I can only think of one other option if there are not that many possible Services:
{
"update": {
"Affected services" : [
{
"set" : [
{{#your expression to gather the service names}}
{ "id" : "{{.}}" }{{^last}}, {{/}}
{{/}}
]
}
]
}
}
If you decide to try this, I recommend writing each variable to the audit log as they are created / updated. That will help diagnose any problems.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In that case you may want to contact Atlassian Support to see if they have other options: https://support.atlassian.com/contact/#/ Please add a link to this thread in your support ticket so they can see what you tried.
When you hear back from them, please post what you learn to benefit the community. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian replied me with a simple instruction that has worked perfectly.
Findings
As you are using a branch to edit the same issue, the values are being set in a race condition. You must add them at once.
Next steps
Remove the branch (keeping its actions), and update the AQL on your lookup action as follows:
Name in ({{issue.description.substringBetween("Serviços: ","Emissores").split(",").trim()}})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Renatao, I have a very similar setup that I am trying to acheive.
Would you be able to share with me how your full rule looks like?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.
Register today!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.