Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Jira automation can not set an Insight object in custom field

Dominique Wille October 3, 2021

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

 

 

4 answers

1 accepted

6 votes
Answer accepted
Nick Thomson
Contributor
December 5, 2021

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 3, 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

Dominique Wille October 3, 2021

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 3, 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.

Dominique Wille October 3, 2021

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

Nick Thomson
Contributor
November 16, 2021

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
František Špaček _MoroSystems_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 29, 2021

@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
Rudy Holtkamp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 3, 2021

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.

Nick Thomson
Contributor
December 5, 2021

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
Mark Liu
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 1, 2023

Wanted to add this on for anyone searching for this issue...

This is for insight objects that utilize a key

Setting the key sets the insight object as the one you want to put in. 

Example:

{
"fields": {
"customfield_id": [
{
"key": "Put key here"
}
]
}
}

Steve Letch
Contributor
April 27, 2023

Yep here's an example of mine where I set two insight fields including a second one that normally only shows its options based on the input to custom field 17700 and also setting a customer request type at the same time

 

{
"fields": {
"customfield_17700": [{
"key": "SQ-349938"
}],
"customfield_17701": [{
"key": "SQ-350003"
}],
"customfield_13704": "Infrastructure Request"
}
}
Leonie C_ Breitmoser
Contributor
January 29, 2024

Here's another addition to your solutions:

If you work with an LookupAssets you can use this json to add the assets from the lookup to an asset custom field:

 

{
"fields" : {
"customfield_XXXXX" :
{{lookupAssets.objectKey.asJsonObject("key").asJsonArray}}
}
}

 

Like # people like this
Alex
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2024

@Leonie C_ Breitmoser it's worked! Thank you !

Like Leonie C_ Breitmoser likes this
0 votes
Muhammet Ayal
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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
Product Admin
TAGS
AUG Leaders

Atlassian Community Events