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

AQL results in regular Jira custom field

Norman March 29, 2023

Hi everyone,

What I am actually looking for is a way to display an 'Assets object' field on a ProForma form. Unfortunately this is not possible with this type of field - see here. Background is that the customer wants/needs to use a ProForma form on the Service Desk.

My next idea was to copy the content of an 'Asset object' field into a regular Jira field (Select list, single choice). This does not work at least with the Scriptrunner Built-in Script 'Copy field values', probably because the field is empty for the script, as it is only filled at runtime via the AQL. Also via an Automation I was not successful at least with my experience.

Do you have any idea how I can get the contents of the 'Assets object' field onto the ProForma form?

Thanks in adavance for any advice.

Norman

1 answer

0 votes
Kevin Newby April 3, 2023

I've got a bit of a temporary workaround, but it's not great bc it uses API calls which are limited to 10mb.

 

Here's how I am doing it for now...

 

1) Created an API User

2) Generated a Personal Access Token for this user (while impersonating them).  Jot down this PAT, you will need it.

3) Go to the System page -> REST API Browser

4) Uncheck the "Show only public API's" box and search for "iql/objects" and choose "insight/1.0/iql/objects"

5) Enter my IQL in the IQL field + the object schema ID number in the objectSchemaId box.  Click on send.  If your IQL is correct, this will provide a URL to use in an upcoming step.  NOTE - If your results are greater than 10 mb, it might be necessary to set include attributes options to false or 0 where appropriate to reduce the response size.

6) Copy the URL provided here and jot it down

7) Go to Manage Apps -> ProForma -> (Data) Connections

8) Setup a new Data Connection.  Give it a name, connection type of REST API, enter the URL obtained in step 5, Authentication = Custom" and enter the PAT identified in step 2.  Set cache results (I used 1 hour) and click next twice.

9) On the configure page I set "Items" to /objectEntries, ID to "objectKey" and Label to "label".  Your settings may be different, but this is what I needed for my setup.

10) Complete/confirm the setup

11) Go to your project and the appropriate ProForma form/field.  Add this Data Connection to this item in your form.

12) This will now result in users being able to select from the appropriate part of your Insight database for this field.

 

That will set the field in the form, but you'll need to create an automation that writes the data provided during intake to the appropriate Insight field.  Welcome to step 2 in this nightmare.

 

Step 2

Assuming you already have a custom Insight field created for this, you'll want to write the information obtained during intake to this Insight field.

1) Create an automation within the project

2) I used "when issue created" as the trigger" and then set an action to re-fetch the data after a .5 second delay.  Then, I added an "Edit Issue" function and used the advanced JSON section as seen below.

 

In this example, my custom field is 11500 and it is the 7th question added to the form.  Note - In the example below, this is the "7".  Yours will likely be a different number.

 

{
    "fields": {
        "customfield_11500": [
            {
                "key": "issue.properties.\"proforma.forms.i1\".design.questions.7.choices.id"
            }
        ]
    }
}

 

After running this automation, Jira is able to fetch the answer provided in the ProForma form and write it to the custom Insight field.

 

Finding the number to replace the 7 in this equation is tricky and difficult.  I needed to test dumping data to my description field multiple times to identify the correct one for each issue type.  This is a nightmare, but it's the only way I've had any success integrating Insight fields with ProForma to date.

Norman April 6, 2023

Hi Kevin,

Thanks for the input. Tbh, that's quite sofisitacted but I want to try.

First show stopper on my side: '3) Go to the System page -> REST API Browser'

Guess you're referrign to the Atlassian REST API Browser. Unfortunately this App isn't compatible with Data Center, so I can't install/use it. Do you have an alternative suggestion how to get the results URL?

Thanks so far,
Norman

Kevin Newby April 13, 2023

Hi Norman - Yes, I am using that Atlassian REST API Browser for this.  FYI - I am am also on Data Center, which says it's not approved...but it does seem to be working for me.

 

I might suggest seeing if you can snag the free trial, map out as many URL's as you can and roll with those?  Not a great solution...Trying to think what else might work though.

 

I looked at a few of my URL's, and you may be able to identify yours via a bit of trial and error via this formula though.

 

https://jira.youraddress.org/rest/insight/1.0/iql/objects?iql=status%20not%20in%20(%22Disposed%22%2C%22Pending%20Registration%22)&objectSchemaid=1

My IQL for this would be - Status not in ("Disposed","Pending Registration") which I'm pulling from an insight table with a Schema ID of 1. (You can find the Schema ID by going into your Insight panel, configuring the schema and checking the URL for the ID)

 

You can see they use %20 for spaces, %22 for " marks and %2C for commas.  So, if you're pulling from an Insight table like I am and you have your object schema + AQL, I think you might be able to figure out the link?

 

Hope this can help - good luck.  Give me a shout if I might be able to help use mine to solve any puzzles you run into.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events