Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Scriptrunner Behaviour copy Insight object attributes to Insight customfield

Hello community,


I have 2 objectTypes "Application" and "Server" in my Insight Schema.

"Application" object has attribute of type "object" called "Application hosts", referencing "Server" objects.

I have also created 2 Insight customfields "CMDB - Server" and "CMDB - Application" linked to these 2 objectTypes and I display them in an "create issue" screen.

I would like to code a behaviour script that displays the "Application hosts" attribute values in the "CMDB - Servers" customfield when an application is selected in the "CMDB - Application" customfield.

Exemple :

object "Application X" has 2 values in attribute "Application hosts" : "Server A" and "Server B".

Then, in the "create issue" screen, when I select "Application X" in the "CMDB - Application" customfield, I would like to have the objects "Server A" and "Server B" automatically selected in the "CMDB - Server" customfield.


Thanks a lot for your help,




2 answers

1 accepted

1 vote
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 25, 2023

You don't need behaviours for this.

This is possible out of the box with Insight Custom field configuration.

Try configuring your "CMDB - Server" as such:

  • Filter Scope (IQL): objectType=Server
  • Filter Issue Scope: object having inR(objectType=Application and Key in (${CMDB - Application${0}})) 
  • Filter Assign Scope (IQL): object having inR(objectType=Application and Key in (${CMDB - Application${0}}))

Now, just leave your CMDB - Server field off the screen and when you create an issue, server objects will be added to the field automatically.

If you absolutely need for the field to be visible and editable during creation, then yes, a behaviour script will be needed.

Create a behaviour with appropriate mapping and add the CMDB Application field.

Create a server-side script and start with a script that looks somewhat like this:


//don't do anything if the issue exists (this means we're currently editing an issue)
def applicationField = getFieldById(fieldChanged)
def serverField = getFieldByName('CMDB - Server')

def selectedApplications = applicationField.value

//no value in Application field, remove server values and exist
if(selectedApplications instanceof String){
selectedApplications = [selectedApplications]

def iqlServer = "objectType = Server and inR(objectType = Application and Key in (${selectedApplications.join(',')}"
def serverObjects =

Hi @Peter-Dave Sheehan 

Thanks a lot for taking time and for this very complete answer but still does not fully resolves my problem.

I admit that I did not fully describe my use case ... :( 

In fact, I have actually 2 attributes in object "Application" .

  • "Application hosts
  • "Database hosts"

And both of them are referencing "Server" objects. (same objectType) ...

I have then 2 Insight custom fields "CMDB - Application Server" and "CMDB - Database Server" that I want to fill in the creation screen (they must be visible and editable yes -> So, I need a behaviour).

  • "Application hosts" attribute values should go to "CMDB - Application Server" customfield
  • "Database hosts" attribute values should go to "CMDB - Database Server" customfield

That's why IQL does not work for my usecase. I really need like a script that copies the attribute values in the corresponding insight customfield.

Any idea ?


Thanks a lot !


Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 25, 2023

That is when the Reference Type in your attribute configuration comes in handy. 

The two attributes that point to Server should have different Reference Types.

Then in the IQL (either type of solution), you can add a second argument to the inboundReference() function (abbreviated to inR() in my earlier response) in the IQL.


object having inR(objectType=Application and Key in (${CMDB - Application${0}}), refType in ("Name of unique Reference Type"))

You can read more about this in (search for referenceType and inboundReferences

Thank you so much @Peter-Dave Sheehan !!!

refType in() was exactly what I was looking for !

Everything is working well now.


Thanks again.


0 votes
Robert Bailey
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.
Oct 25, 2023

Hi @Aimane SBAI ,


ScriptRunner behaviours on Server/DC support Asset custom fields, so you should be able to get the value of the "CMDB - Application", and set the values of the "CMDB - Server" in the same way you would normal fields. 

If you are on version 7.11 or above of ScriptRunner, you are able to use the HAPI Assets/Insight module to easily access the information of the Asset you have selected in the "CMDB-Server" field. You can find the documentation of how to do this here:

Does this help?

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events