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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 set custom filed value based on other filed value when creating Request from Customer Portal Edited

Lets say I have 2 custom fields:

  1. Select list which contains of: Item1 , Item2, Item3 and etc.
  2. Checkboxes item which is empty

 

I want to create behavior when, user creates a request from a Customer Portal, and selects from Select list lets say Item1, then items in Checkboxes change to my defined custom values.

When user selects Item2 in Select list, then items in Checkboxes change to other custom values which are expected for Item2

I tried to find code for ScriptRunner plugin, but none of them helped. 

1 answer

1 accepted

0 votes
Answer accepted

Hi @Akshin Mustafayev 

Share your script and let us see why it is not working.

You can also take a look at this script and this one as well to get some some examples.

Ravi

Hi Ravi,

Thanks for the links. I tried to perform steps in the articles and achieved some progress. 

I have put this script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager;

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.customFieldManager
def optionsManager = ComponentAccessor.optionsManager

def foldersField = getFieldById(fieldChanged)
def subfoldersField = getFieldByName("Subfolders")

// Get the all the options of Subfolders
def subfoldersCF = customFieldManager.getCustomFieldObjectsByName("Subfolders")[0]
def config = subfoldersCF.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)


// Checks
if (foldersField.value == "folder1") {
def newOptions = options.findAll { it.value in ["subfolder1", "subfolder2"] }
subfoldersField.setFieldOptions(newOptions)
}
else if ((foldersField.value == "folder2")) {
def newOptions = options.findAll { it.value in ["subfolder2", "subfolder3", "subfolder4"] }
subfoldersField.setFieldOptions(newOptions)
}

 

I can not find how to properly clean Subfolders checkboxes field values when request has been opened the first time. I want values appear only when foldersField item has been selected.

I tried to hide Subfolder field on initialize step:

getFieldByName("Subfolders").setHidden(true)

But when I put 

// Checks
if (foldersField.value == "folder1") {

getFieldByName("Subfolders").setHidden(false)
def newOptions = options.findAll { it.value in ["subfolder1", "subfolder2"] }
subfoldersField.setFieldOptions(newOptions)
}
else if ((foldersField.value == "folder2")) {

getFieldByName("Subfolders").setHidden(false)
def newOptions = options.findAll { it.value in ["subfolder2", "subfolder3", "subfolder4"] }
subfoldersField.setFieldOptions(newOptions)
}

 nothing happens (field does not want to appear).

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