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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Dynamically assign value to Affected Services field via JSM Automations Edited

Hello Community

 

Is there a way to copy one field value to another, where source field is text, and destination (to copy it to) is a drop down like Affected Services, or any other Insights field.

The idea is:

My form has a Dropdown of X values, which contain List of Services i want users to use on this form. My Insight Services list contains Y items, thats why I want users to restrict it to be able to select only some of the services.

Via Automation i want to get that value of Drop down list and "Assign it" to Affected Services form field which is and Insights object field.

 

2 answers

1 accepted

0 votes
Answer accepted

@Alex van Vucht _GLiNTECH_ thanks for your response.

 

However it does not appear to work, setting value  {{issue.Service Objects.Name}} in the selected Affected Services, does nothing (affected services tries to run autocompletion, nothing is found, and the input box is cleaned up.

Instead, i have selected

  1. When: Value changed for Service Objects
  2. If/else block:
    1. If: Service Objects are empty
    2. Then: Edit issue: Affected Services: Blank, ie. clear this field
    3. Else:
    4. Then: Edit issue: DO NOT Choose fields to set
    5. Click on More options, and under Advanced, specify:
      {

      "fields": {

      "Affected services":[{"id": "{{issue.Service Objects.Service ID}}"}]

      }

      }

       

If you Service Objects field (which is a custom Insights object field type) accepts multiple values, you might as well wanna use Jira's loop-over-list template stanzas: 

{
"fields": {
"Affected services":[{{#issue.Service Objects}}{"id":"{{Service ID}}"}{{^last}},{{/}} {{/}}]
}
}

if you don't want to use loop stanzas we can rather use this shorthand

{
"fields": {
"Affected services":{{issue.Service Objects.Service ID.asJsonObjectArray("id")}}
}
}

this documentation is taken from: https://support.atlassian.com/jira-software-cloud/docs/advanced-field-editing-json

I've been doing some work with the Affected Services field recently and it's a little special. It uses the OpsGenie API, not the Insight Cloud API.

You'd have to create a separate Insight Object custom field for the Services schema so that you can then set an IQL query to restrict the options. I'll call this field "Service Objects" but you can call it whatever you like.

Try this:

  1. When: Value changed for Service Objects
  2. If/else block:
    1. If: Service Objects are empty
    2. Then: Edit issue: Affected Services: Blank, ie. clear this field
    3. Else:
    4. Then: Edit issue: Affected Services: {{issue.Service Objects.Name}} 

I'm not too sure how well this will work if multiple services are selected. Working with smart values for multiple selections gets messy, especially with Insight objects. Get it working first for a single selection then expand from there.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

Atlympic Event: Jira Service Managemnt

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

149 views 0 3
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