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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,304
Community Members
 
Community Events
176
Community Groups

Send API request Behaviour

Hi,

 

I have a behaviour that converts another field into a MultiSelect list and retrieves the values of that list from an API REST, as we can see on the "Walkthrough - External REST Service" section of this official page: https://docs.adaptavist.com/sr4js/latest/features/behaviours/behaviours-examples/select-list-conversions

 

My multiselect list works fine when I'm on a form and I change another values. However, instead of show the label of every option in the list, I see the value key, which is stored in the field. How can I show the label instead of the value such as it works with the behaviour?

 

Next is the code of my behaviour and how I build the multiSelect list:

 

import com.atlassian.jira.component.ComponentAccessor
def
tipoCaso =  getFieldByName('Tipo de caso')
def servicio =  getFieldByName('Servicio SalesForce')
def modulo =  getFieldByName('Módulo SalesForce')
def campoServicio = ComponentAccessor.customFieldManager.getCustomFieldObjects(underlyingIssue).findByName('Servicio SalesForce')
def valorActualServicio = underlyingIssue.getCustomFieldValue(campoServicio).toString()

log.debug("Valor actual servicio")
log.debug(valorActualServicio)
log.debug("Valor cambio")
log.debug(getFieldById(getFieldChanged()).getValue().toString())

if (getFieldById(getFieldChanged()).equals(servicio) && (getFieldById(getFieldChanged()).getValue().toString() != valorActualServicio)) {
    modulo.setFormValue(null)
    def getOptionById = servicio.value.toString()//ComponentAccessor.getOptionsManager().getAllOptions().find{it.optionId == fieldChanged.value.toString()}

    log.debug("Cambia el servicio")

    modulo.convertToMultiSelect([
        ajaxOptions: [
            url           : getBaseUrl() + "/rest/scriptrunner/latest/custom/fnModulosPorServicio?servicioId="+getOptionById,
            query         : true, // keep going back to the sever for each keystroke
            minQueryLength: 4,
            keyInputPeriod: 500,
            formatResponse: "general",
        ]
    ])
}

 

And this is what I see on the jira view, or when I tried to edit the fields:
imagen.png

 

Thanks in advance!

1 answer

Hi @fromero88

I have read through your description, and I have a doubt, i.e. when do you want your Behaviour to take place?

Is it when you are creating a new issue or when you are editing an issue? If it is the former, your code may not work as expected because the underlyingIsuse will only be accessible after the issue has been created.

Secondly, why are you using the approach below to invoke the Sales Force field?

def campoServicio = ComponentAccessor.customFieldManager.getCustomFieldObjects(underlyingIssue).findByName('Servicio SalesForce')

Why not just invoke it as:-

def campoServicio = getFieldByName('Servicio SalesForce')

Also, if you could share a screenshot of your Behaviour configuration, it would be helpful to get a better understanding.

Looking forward to your feedback.

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events