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

How to update fields via script (listeners)? Edited

Hello, im trying to update filed to null value with listeners. Aftet update logs shows me nothing, no errors, but nothing is changed, field still not empty. What wrong with my script?

 

short description of script: if value 1 == error or customization; then value 2 = null, then value 3 = null and ect

 

type fields:

value 1 - (type: Deviniti [Dynamic Forms] - Dynamic Select)

value 2 3 and others ( types: Deviniti [Dynamic Forms] - Dynamic Select, multiple select list, text field)

 

Script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.CustomFieldManager

def issueManager = ComponentAccessor.issueManager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issue = event.issue


def field_1 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Тип запроса")
def field_2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Пояснение к ЭФ")

def newValue = issue.getCustomFieldValue(field_1)

if (newValue =="Ошибка"){

field_2.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(field_2), null), new DefaultIssueChangeHolder())
}else if (newValue =="Настройка"){

field_2.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(field_2), null), new DefaultIssueChangeHolder())
}

image-2021-06-15-00-05-56-366.png

1 answer

0 votes

My suspicion is that you can't update Devinity Dynamic Form fields like that. This is okay for most regular custom fields.

With Dynamic form, what you actually want to use their own API: https://deviniti.com/support/addon/server/dynamic-forms/latest/bundled-fields-java-api/

I have no experience with that. I just found the reference page.

All right, thnk u! I'll rebuild script and back soon. 

PS: few days ago devinity custom field was hidden by regular script. I think something wrong with current script, cause i cant change even regular textfields :(

I made it. Just needed to use next if (newValue.toString() =="Ошибка")

Suggest an answer

Log in or Sign up to answer
TAGS

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