Can we set a custom field as mandatory based on other custom field value in same transition screen ?

We have configured a transition Namely "Detail Analysis Completed". In this Transition there is 2 fields -

1) Global in nature? [ Field Value = 11425 ]

2) Target Project Name(s) [ Field value = 11426 ]

In "Global in nature?" field there is 2 values -

1) Y [ valueid = 11588 ]

2) N [ Value ID = 11589 ]

Now we Need to set "Target Project Name(s)" field as mandatory when "Global in nature?" field value is "Y". Please note both "Global in nature?" and "Target Project Name(s)" are in same transition screen. Do we need to set any post function/condition/validator for that? If yes, then could you please provide us steps ?

Thanks in advance

Sumit Mitra

2 answers

I have using below mentioned script in Behavior Plugin but not working -

FormField pro = getFieldById("customfield_11425")
FormField ecp = getFieldById("customfield_11426")
 
String vpro = (String) pro.getFormValue()
String vecp = (String) ecp.getFormValue()
 
//to see values near fields uncomment sentences
// pro.setHelpText("vpro: "+ vpro)
//ecp.setHelpText("vecp: "+ vecp ) 
 
  if (vpro == "Y") {
              ecp.setRequired(true)
  }else{
        ecp.setRequired(false)
 }

Could you please look into this

There may be other ways to do this, but one way is using a validator. Specifically, Conditioned validator that will return to the user if the condition is not met for them to do whatever is needed to allow the transition to proceed, like updating issue fields either from the transition screen or elsewhere. You use Substitution variables to retrieve the transition variables (in your case) to condition and also to construct a nice error message for the user.

I am not understand how can we implement this. Previously we have succuessfully impleamented "Show a particular customfield based on another customfield value" by configuring customised plugin using js script. Please find the js script below for previous case -

jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
    callChangeFunction();
});
callChangeFunction();
function  callChangeFunction(){
        showHidField();
        // dropdown custom field change function
    $("#customfield_10020").change(function() {
        showHidField();
    });

}
    function showHidField(){
        //drop down field selected value
        var dropDownFieldval =
        $.trim($("#customfield_10020 :selected").text());
            //test field1
            $("#customfield_10221").closest('div.field-group').hide();
        if(dropDownFieldval == 'New Machine Required'){
            $("#customfield_10221").closest('div.field-group').show();
        }

    }
});

Can we using same procedure for "set a customfield required based on another customfield value" ? If so then could you please provide us the steps?

Hi Prasad/Bob,

Any update on this issue ?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Jira

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,080 views 0 8
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