Issuecreation, if the value of a field"Sourceofchange request"=Customer thenthefield

mummareddy supriya
Contributor
October 14, 2024

While Issue creation, if the value of a field "Source of change request" = Customer then the field "External Issue ID" should be made mandatory. I tried with behaviours and listens too in Scriptrunner but its getting mandatory field option while submitting state  .But i need to get it while creation of issue.

external field.PNG

import com.atlassian.jira.component.ComponentAccessor // Get the custom field manager def customFieldManager = ComponentAccessor.getCustomFieldManager() // Get the fields by name def sourceOfChangeRequestField = getFieldByName("Source of Change Request") def externalIssueIdField = getFieldByName("External Issue Id") // Get the current value of "Source of Change Request" def sourceOfChangeRequestValue = sourceOfChangeRequestField.getValue() as String // Check if the "Source of Change Request" is set to "Customer" if (sourceOfChangeRequestValue == "Customer") { // If "External Issue Id" is empty, show an error and prevent submission if (!externalIssueIdField.getValue() || externalIssueIdField.getValue().toString().trim().isEmpty()) { externalIssueIdField.setError("External Issue Id is required when 'Source of Change Request' is set to 'Customer'.") } else { // Clear the error if the field is filled externalIssueIdField.clearError() } } else { // Clear any existing error if "Source of Change Request" is not "Customer" externalIssueIdField.clearError() }

1 answer

1 accepted

1 vote
Answer accepted
Stephen_Lugton
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 14, 2024

@mummareddy supriya Jira doesn't perform any form of validation until an issue is created, as such, it is not possible to change values / settings automatically during the creation process.  In addition, whether a field is mandatory or not is defined by the schema used by the issue and cannot be changed during issue creation.

mummareddy supriya
Contributor
October 14, 2024

Thanks for your suggestion @Stephen_Lugton 

Suggest an answer

Log in or Sign up to answer