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 hide certain values in a single select custom field on Jira service Desk customer portal?

Hello All,

We have Organized Jira Service desk Request Types to multiple Groups to appear in the customer portal Ex: Jira, Confluence, Bitbucket and Bamboo.

Each Group has multiple Request types For Example: Jira has following Request types New Account, modify Field, Edit Project, Reporting and Bug.
Group confluence has following Request types New Confluence Space, Additional functionality, Bug and Performance

For Groups Jira and confluence has following fields on Customer portal Summary, Description, Attachment and Servers. Servers custom field has following Options Server1, Server2, Server3 and Server4.

Now we want to Restrict the values on the Servers field depend on the Request Type group. Ex - If user selects a Group Jira and Request name Bug on the customer portal Servers field
has to show following options Server1 and Server2 and same way if user selects Confluence group and Request name Bug Servers field has to show only following options Server 2 and Server 3.

To achieve this we have added below script in the behavior and mapped to Jira service desk project and All Request Types. But script is not working it is showing error in the attached screen shot.

import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.servicedesk.api.requesttype.RequestType
import com.atlassian.jira.user.ApplicationUser


@WithPlugin("com.atlassian.servicedesk")

RequestTypeService requestTypeService = ComponentAccessor.getOSGiComponentInstanceOfType(RequestTypeService)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ApplicationUser user = ComponentAccessor.getUserManager().getUserByName(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().name)
RequestType getRequestType = requestTypeService.getRequestTypeForIssue(user, underlyingIssue).right().get()

def issueField = getFieldByName("Server")

def customFieldManager = ComponentAccessor.getCustomFieldManager()

String requestTypeName = getRequestType.getName()

def optionsManager = ComponentAccessor.getOptionsManager()

def customField = customFieldManager.getCustomFieldObject(issueField.fieldId)
def config = customField.getRelevantConfig(getIssueContext())

def options = [:]
def listOpt = ["Server1", "Server2"]
def listOpt1 = ["Server3", "Server4"]

if ("Jira".equals(requestTypeName)) {
options = optionsManager.getOptions(config).findAll{ it.value in listOpt }
issueField.setFieldOptions(options)
}
else {
options = optionsManager.getOptions(config).findAll{ it.value in listOpt1 }
issueField.setFieldOptions(options)
}

Behaviour.PNGThanks in advance,

ch

0 answers

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