How to update a JSM issue Insight field with multiple values without overwriting the existing value
Asked by Boswell, Richard:

**TL;DR - is it possible to simply add a value to a JSM Insight-backed custom field without overwriting the existing values?**

*** ** * ** ***

We are doing a PoC with Insight as our CMDB and have two schemas, one of which has an object type named Business Application, a second schema that has an object type named Virtual Machine. We link each Virtual Machine object to a Business Application using an outbound reference.

We have a JSM incident request type called *Report a system issue* . The JSM form has two custom Insight fields: Affected Business Application(s) (that is tied to the Business Application Insight object type) and Affected IT Asset(s) (tied to the Virtual Machine Insight object type). During creation of a *Report a system issue* incident request type, populating the Affected IT Asset(s) field is required and the Business Application field is hidden.

We would like to use a Global Automation rule to retrieve the business application object linked to the VM object(s) specified in the Affected IT Asset(s) field and then update the business application custom field with that object. We have developed a Global Automation rule which works for a single VM assigned to a single business application and multiple VMs assigned to a single business application. That solves two of our three use cases but not the most complex.

Our most complex use case is probably best described using an actual real world use case - let's say an ESXi hypervisor server crashes. At the time of the crash the ESXi server was hosting 20 VMs. We have developed automation outside of JSM that updates the linkage of our VMs to ESXi servers in real-time, so in this use case we know exactly what VMs where running on that ESXi server when it crashed. An incident issue is automatically created using the Report a system issue and the ESXi host and each VM running on that host at the time of the crash is linked to the incident issue via the Affected IT Asset(s) Insight. Each VM potentially could be part of a different business application so we need to get the business application linked to each VM and add them to the Affected Business Application(s) custom field.

Today's challenge is how to execute the same process when multiple VM objects are assigned that are linked to different business applications. Branching is used currently to execute the Insight lookup for the VM to retrieve the linked business application. Next a step was added that simply edits the Affected Business Application(s) custom field on the issue. The problem is that each subsequent iteration of the For each: Smart value step overwrites the existing Affected Business Application(s) value, resulting in only the last iteration's value written.

I'm stumped here, in standard coding I would simply add the business application object to an array during each iteration and then build the Insight set array at the end. But since variables set within a branch cannot be "globalized" this wouldn't work (let alone trying to figure out how to build the Insight set array). I did try to set the "Copy from" option on the Edit Issue rule and targeted the Affected Business Application(s) from Current issue but my issue here is that I have to use the advanced field editing More options "fields" declaration to successfully edit the Insight-based custom field.

Any ideas?


Answers:
author: Boswell, Richard
body: Well unfortunately I could not find a way to do this with Global Automation directly. Instead I wrote an AWS Lambda function that is triggered by Global Automation and that code takes care of add the multiple business applications back to the incident.


author: Dan Tombs
body: Hi [@Boswell, Richard](/t5/user/viewprofilepage/user-id/4758099)

If I have understood the above correctly. Are you able to use something like:

{{issue.customField_1000}}, \<new value\>

The reason for the smart value is os that it will retain previously entered values. You may also want to double check and see that your custom field can actually take multiple values in it. Go to custom fields, configure and then edit the configuration to check.

Dan

comments: author: Boswell, Richard
body: [@Dan Tombs](/t5/user/viewprofilepage/user-id/4172448)unfortunately no, the problem when appending the additional values is actually getting the other values in the other branches. Yes the custom field accepts multiple fields, it isn't that I can't add them, it's that I can't add them without blanking the existing value.


Tags: insight