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

Hide/show field using ScriptRunner Behaviours

Zaldy Parian
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.
Oct 26, 2023

Hi all,

Just starting to explore ScriptRunner.

I got a radio button custom field "Resoved on first call" (id=10219) with default value of "No". And another custom field "Resolution comment" (id=10215). 

I want to hide the Resolution comment field if the Resolved on first call is = "No".

My script looks like this....


const reso_1call = getFieldById("customfield_10219");
const reso_comment = getFieldById("customfield_10215");

logger.info('Value : '+ reso_1call.getValue().name);

if(reso_1call.getValue().name == 'Yes'){
    reso_comment.setVisible(true);
    logger.info('true');
} else {
    reso_comment.setVisible(false);
    logger.info('false')
}

The script has red undeline on customfield_10219 and .name.

If I hover my mouse on customfield_10219, the message is... "Argument of type '"customfield_10219"' is not assignable to parameter of..."

And hover on .name, the message is... "Property 'name' does not exist on type 'string..."

What am I doing wrong?  Please help.

 

1 answer

0 votes
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 27, 2023

Hi,

You need to do something like this:

const checkbox = getFieldById("customfield_02133").getValue();
//will return this:
[{"id":"10021","value":"A"},{"id":"10022","value":"B"}]

https://docs.adaptavist.com/sr4jc/latest/features/behaviours/behaviours-api

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events