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

Sys Admin March 5, 2014

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

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
March 5, 2014

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.

Sys Admin March 6, 2014

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?

Sys Admin March 6, 2014

Hi Prasad/Bob,

Any update on this issue ?

0 votes
RambanamP
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.
March 5, 2014
Sys Admin March 5, 2014

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

Suggest an answer

Log in or Sign up to answer