Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,301,203
Community Members
 
Community Events
165
Community Groups

Jira automation can not set an Insight object in custom field

Hey guys

 

Having Insight configured, with plenty of objects.

HWC-1 to HWC-300

 

In Jira automation, trying to make an automation to set an Insight object "Factory" on custom field 10772 when user has selected proper factory name

You can not choose Insight custom field field (I mean i could for a while but then it disappeared) so using "More options".

Using that code

{
"fields": {
"customfield_10772": [{ "set" : [{"key":"HWC-30"}] }]
}
}

I can see that something happens (because the field gets blanked if something was in it) but definitively whatever what I tried, it just does not work.

What to do ?

And if I arrive to it, how to use {{lookupObjects}} (which already displays HWC-30 in logs) ?

thanks

 

 

3 answers

1 accepted

5 votes
Answer accepted

Re-posting as an answer rather than a comment.

I eventually got this to work, but the documentation was not helpful.

Get your insight workspace ID via the REST endpoint via a logged in browser:

https://<workspace>.atlassian.net/rest/servicedeskapi/insight/workspace

In your IQL triggered automation step - which has access to the resulting {{Object}}s, via additional JSON, use:

{
  "fields": {
    "customfield_10135": [{
      "id":"abcd-abcd-1234-abcd:{{Object.id}}"
    }]
  }
}

Where customfield_10135 is the custom field ID of your *Insight objects* custom field (NOT assets), and abcd-whatever is the workspace ID from your REST result.

In the example above, you'd use:

"customfield_10772": [
      {
        "id": "82b9f04d-8bdc-47c7-9211-8787900659fa:24"
      }
    ]

 

Hope this helps!

1 vote
Fabian Lim Community Leader Oct 03, 2021

Hi @Dominique Wille

If you want to set an object in an insight custom field you actually have to use the full field information of an object.

In the jql search lin advanced mode and lookup your field with the object you want to use. It will be a long string that includes the hwc key + the actual name of the object.

Try copying that full string and pasting it to your automation rule.

Regards

Thansk for answer.

However I am not sure I get it. So far my understanding is that information is not duplicated in the issue, but it is a pointer that points to an Insight object.

When I do a "get issue" I get only pointer info.

"customfield_10772": [
      {
        "workspaceId": "82b9f04d-8bdc-47c7-9211-8787900659fa",
        "id": "82b9f04d-8bdc-47c7-9211-8787900659fa:24",
        "objectId": "24"
      }
    ]

 

What I need to have is something dynamically, so no need to copy anything anywhere.

 

1 - In the triggered automation rule (field edited), get the Insight object (OK) 

objectType = "Factory" AND "Factory label"={{fieldChange.toString}}

this gives me a nice 

{{lookupObjects}} 

In logs, I see content (maybe mapped) is "HWC-30" or other, works ok dynamically

 

2 - Edit the Insight custom field, in the issue that triggered automation

I do not want to do anything in Insight itself.

The  "official way" of setting a field does not work with {{lookupObjects}} so I am trying first manually with a key.

I tried also to blank the field, and push workspaceId, id, and objectId, but still no luck.

 

Annoying... maybe there is something else.

Like Fabian Lim likes this
Fabian Lim Community Leader Oct 03, 2021

Ah I see.  

I would use the built in insight postfinctions then. There is one about writing a value based on a insight customfield selection. However, they only work when you are performing a transition.

So if you want to edit it, you need to create a transition that calls itself with a transition screen that provides the insight custom field that makes the initial selection.

I hope this helps.

Would like to find something a bit more elegant...

I eventually got this to work, but the documentation was not helpful.

Get your insight workspace ID via the REST endpoint via a logged in browser:

https://<workspace>.atlassian.net/rest/servicedeskapi/insight/workspace

In your IQL triggered automation step - which has access to the resulting {{Object}}s, via additional JSON, use:

{
  "fields": {
    "customfield_10135": [{
      "id":"abcd-abcd-1234-abcd:{{Object.id}}"
    }]
  }
}

Where customfield_10135 is the custom field ID of your *Insight objects* custom field (NOT assets), and abcd-whatever is the workspace ID from your REST result.

In the example above, you'd use:

"customfield_10772": [
      {
        "id": "82b9f04d-8bdc-47c7-9211-8787900659fa:24"
      }
    ]

 

Hope this helps!

Like # people like this

@Nick Thomsonyou sir are a hero.

 

For those looking for complete solution:

First you have to use action "Object lookup" where you can use smart values. In my case I used:

objectType = Organization AND "Name" = "{{issue.Name of the organization}}"

This saves result in another smart value {{lookupObjects}}

You then have to find insight id of your instance as stated above.

Then you can use "Edit issue", turn on advanced mode and have something like this:

{
"fields": {
"customfield_10060": [{
"id":"abcd-123456-efgh-asd65dca:{{lookupObjects.id}}"
}]
}
}

Beware that I haven't tried this for multi object field - it might need a bit different.

Like # people like this

I second that!

@Dominique Wille can you please accept the answer of @Nick Thomson

It will help a lot of people who are facing the same issue.

Thanks @Rudy Holtkamp @František Špaček _MoroSystems_ . As I originally posted a comment reply, I have reposted as an answer below.

Glad I could be of help!

0 votes
Muhammet Ayal Community Leader May 28, 2022

Hi Team, 

This is work for me, thanks

 

{
"fields": {
"customfield_10520": [{
"id": "956a4a68-32e1-4216-bab3-edcf04027c1e:2248"
}]
}
}

Screenshot 2022-05-28 145358.png

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Jira Service Management

Improving the Create Issue Experience in Jira Service Management Cloud

Hello everyone!  We are very excited to announce some much needed changes to the issue create experience in JSM (the blue "create" button) at the top of the screen.  We have just starte...

295 views 15 9
Read article

Community Events

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

Events near you