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

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

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()' )

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();
}
});

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

64 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you