Custom Field Required if Another Custom Field Selected

I need to make a custom field mandate based on the fields i chose in the screen for a project.
When doing below transition in workflow"In Analysis" -> “Pending A” with reason “Waiting for Approval”.
Must have for this transition:
*Functional Requirement Specification (FRS) document;
*Estimations.

I have created a screen and fields but i couldnt modify according to the behavior.I want the custom fields to go as mandate only when the reason for pending field has waiting for Approval status.

For rest of the status the field values shouldnt display in screen.Please help as its urgent requirement.Attached screenshot for better understanding.

Help me with the changes using scripts.

Hi Arthi,
what about following solution with Behaviours (part of ScriptRunner)?

  • Define new behaviour on yourJiraBaseUrl/secure/admin/Behaviours!default.jspa? with desired name
  • Select project(s) and issue type(s) by clicking on Add Mapping
  • By clicking on Fields open dialog and define own behaviour as follow:
    • Guide workflow: Your workflow
    • I guess no initializer is necessary
    • Add field with name Functional Requirement Specification (FRS) document
      • Switch the first toggl button to make field mandatory
      • Add new condition – select workflow action “In Analysis” -> “Pending A”
      • Add following script:
def reason = getFieldById("customfield_xxxxx").getValue()

def frsCf = getFieldById("customfield_yyyyy")
def estimations = getFieldById("customfield_zzzzz")

if (reason.equals("Waiting for Approval")) {
    frsCf.setHidden(false)
    frsCf.setRequired(true)
    estimations.setHidden(false)
    estimations.setRequired(true)
} else {
    frsCf.setHidden(true)
    frsCf.setRequired(false)
    frsCf.setFormValue(null)
    estimations.setHidden(true)
    estimations.setRequired(false)
    estimations.setFormValue(null)
}

Maybe some adjustments will be necessary – I didn’t try it.
Hopefully, it will help you.

Regard
Josef