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

Can you use Behaviours on Customer Portal Affects Version/s ?

slothstronaut February 2, 2018

Hi there! 

The goal I'd like to achive, is to only show released and not yet archived versions in the Affects Version/s Field in JIRA Service Desk Customer Portal.

I tried this in vain using the new (and still awesome) Behaviours Service Desk support.

 

import com.atlassian.jira.component.ComponentAccessor


//getting version Manager
def versionsManager = ComponentAccessor.getVersionManager()

//getting the Affects Version/s Field
def versionsField = getFieldById("versions")

//getting all non-archived released versions
def releasedVersions = versionsManager.getVersionsReleased(issueContext.projectObject.id, false)

//setting them as FieldOptions for the Affects Version/s Field
versionsField.setFieldOptions(releasedVersions)

 

When printing out all versions of this project and the ones in releasedVersions, I get the following result:

 

image.pngREL = only released and non archived versions           

ALL = all versions

 

I tried this with and without the BaseScript import at the start of the script, but ...

import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

 ... I still got all the versions shown in the customer portal without any error. (What it the BaseScript line doing anyways?) 

 

image.png

Does anyone know if this is a general problem at the moment or am I doing something completely wrong? 

Thanks in advance!     

 

3 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Najjar _Innovura_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 16, 2020

Hi @slothstronaut 

We recently launched a new app that allows to prompt users for the affected version on customer portal.

The form would show a project field with cascading version and/or component

You may try it on our demo environment

http://jira.innovura.io/servicedesk/customer/portal/1/create/1

Feel free to contact us if you want any enhancements/modifications 

Here's the link for the app:

https://marketplace.atlassian.com/apps/1221971/jira-confluence-workflow-extensions-jcwe?hosting=server&tab=overview

0 votes
slothstronaut February 27, 2018

Additional Console Log Information: 

consoleLog.png

Behaviours is getting the right value, but then exits with an error

Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 27, 2018

Hey @slothstronaut and @Yves Martin ,

There is a known issue for setting values to select lists using service desk behaviours. 

Please follow SRJIRA-2687 for updates (I can tell you that there is a Pull Request already so hopefully the fix will be included in the next release)

Regards, 

Thanos

Yousaf February 27, 2018

Off toppic..

 

Hello Thanos,

 

could you please check out this post? I would really appreciate it if you answered this question ;) Thanks! 

 

https://community.atlassian.com/t5/Jira-questions/auto-add-organization-on-creation-of-ticket/qaq-p/25440#U733256

slothstronaut February 28, 2018

Thanks!

0 votes
Yuriy Lozhkin February 20, 2018

Hi, slothstronaut! I have a similar problem with the script. When creating a new task in JIRA, script works ok, but if we create a new task in Service Desk portal, script doesn't work. Through the browser console I have such an error:

Behaviours post failed. TypeError: Cannot read property 'map' of undefined
at Object.a [as f] (batch.js?locale=en-US&sd_operational=true:1044)
at Function.e.setFieldOptions (batch.js?locale=en-US&sd_operational=true:1044)
at t.e.addFieldListeners (batch.js?locale=en-US&sd_operational=true:1044)
at batch.js?locale=en-US&sd_operational=true:1044
at <anonymous>

You get the same error?

slothstronaut February 20, 2018

no, "unfortunately" im not getting any error response in the logs. Maybe I am misinterpreting the docs.

edit: 

i can see my script getting triggered, but it seems like the .setFieldOptions doesnt have any effect. 

Yuriy Lozhkin February 20, 2018

maybe we misunderstand each other, I've enabled logging for behaviour and also include logger to my script for debug. I can see my script is called during my browser
https://screenstore.tk/2018-02-2017-51-18bgv2m.png

Yves Martin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 27, 2018

Hello

You faced similar bugs to what I reported about "select list conversion": https://productsupport.adaptavist.com/browse/SRJIRA-2667

It looks like jQuery "$" alias is not defined - and replacing "$." and "$(" in plugin js/bh-portal.js (by "jQuery." and "jQuery(") may be a work-around  worth to try... waiting for Adaptavist to fix this Behaviour support.

I propose you to vote for my bug report, and I can vote for yours if you create one for your specific trouble.

slothstronaut February 27, 2018

maybe only an Adaptavist could clarify the situation here =)

If its generally possible to modify the customer portal of a service desk project via behaviours, or just the service desk project itself (inside normal jira without the effects on the customer portal).

Yves Martin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 27, 2018

Right. But the way "Behaviours with Service Desk" is documented: https://scriptrunner.adaptavist.com/latest/jira/behaviours-servicedesk.html

it sounds like any documented "behaviour use case" is expected to work in both JIRA and Customer Portal.

TAGS
AUG Leaders

Atlassian Community Events