How to hide a message custom field on edit screen for a status

Vineela Durbha January 18, 2018

Hi,

I have a message custom field(edit)and I am trying to hide that field on edit screens of certain status.

Eg:- I would like hide the field for status=Submit and show when status=create.

 

Can someone help me on this as I am not able to do it with Behavior plugin and field appearance plugin.

I tried with Jquery as below 

AJS.$(document).ready(function () {

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
var status = AJS.$("#status-val").text().trim();
if (status == "Created"){
AJS.$('#TextField_PR_Approval').show();
}
else
{
AJS.$('#TextField_PR_Approval').hide();
}

});

});

 

Above code is working for tranistions but not on Edit screen.

 

Looking for a help on this

1 answer

0 votes
Domenico Manzo _Actonic_
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.
January 18, 2018

I've just checked similar script on my environment and it works properly.

Please have a look:

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, 
    function (e,context) {
        var status = AJS.$("#status-val").text().trim();
        if (status != "Done"){
            AJS.$('#customfield_10304').parent().show();
        } else {
            AJS.$('#customfield_10304').parent().hide();
        }
    });

 Pay attention:

1. You should use proper custom field ids (like 'customfield_10304', not 'TextField_PR_Approval')

2. You should hide not only the field element, but the field wrapper ( '.parent().hide()' )

Vineela Durbha January 19, 2018

I tried the above but didnt help,It is able to hide the field on tranistion screens but not on Edit screen.

 

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED,
function (e,context) {
var status = AJS.$("#status-val").text().trim();
if (status == "Created"){
AJS.$('#customfield_19903').parent().show();
} else {
AJS.$('#customfield_19903').parent().hide();
}
});

Muhammed Sharifi October 17, 2018

the above function didn't work for me too. 

Mahesh Kallepalli February 3, 2022

@Vineela Durbha 

Kindly let me know if you got a solution for this. Currently, we want to hide a few message fields. I tried the above script but had no luck.

Suggest an answer

Log in or Sign up to answer