Hide custom field based on workflow status in Jira Cloud using scriptrunner behavior

Digvijay Singh Gehlot
Contributor
November 27, 2024

Hi Community,

I am creating a behavior in Jira Cloud using scriptrunner.

I want to hide a custom field based on workflow status using scriptrunner cloud behaviors:

For example: custom field as "Service" and status as "To Do", so when an issue reaches to status "To Do" then the custom field "Service" should be hidden on the view screen.

Please guide further with the required code.

Thanks

1 answer

1 accepted

2 votes
Answer accepted
Marc - Devoteam
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.
November 27, 2024

Hi @Digvijay Singh Gehlot 

I'm no export, but a quick scan on the behaviours documentation shows that status information can only be used by the status id, not the name.

See, behaviours-supported-fields-and-products 

But only on Jira and Company Managed projects, so no JSM and Team Managed projects

Digvijay Singh Gehlot
Contributor
November 27, 2024

Hi @Marc - Devoteam 

Thank you so much for sharing that useful document, it helped me to configure the getValue logic in scriptrunner cloud behavior.

I also referred to these help documents below:

I would like to share my sample code on how to hide a custom field based on workflow status using scriptrunner cloud behavior with community as below:

const cField = getFieldById("customfield_XXXXX")

const statusField = getFieldById("status");

const statusFieldValue = statusField.getValue() ? statusField.getValue().name : null

if(statusFieldValue == "To Do"){

    cField.setVisible(false)

}

else{

    cField.setVisible(true)

}

Please let me know if it needs any further refinements or any other logics, we can use to achieve the requirement. It will be a great learning for me.

Thanks

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events