Jira: Require field based on reporter

Our IT support team creates tickets in Jira for things submitted to the helpdesk that need to be handled by the development team. If the person that submitted the original ticket is a Jira user, they’ll change the reporter to that person. Otherwise it gets left as the shared account used by the helpdesk (username: helpdesk). In those cases, the helpdesk is supposed to enter the users information in the description. We’ve been having issues lately where they don’t do this. We wanted to add a required custom field Original Requestor, but making it required would be annoying for any other users entering tickets, as well as cases where the helpdesk was able to change the reporter.

Using the script runner plugin, I was able to create a custom validator that only requires the field be populated when the reporter is helpdesk. I had to piece this together from a few different forum posts and digging through the Jira class documentation. I figured I’d share my solution in case anyone else needs to do something similar.

This is what the error looks like if the helpdesk user does not provide a value for the ‘Original Requestor’ field

A few additional things

  • I couldn’t figure out how to get the message to show under the Reporter field and have the label in the top part say “Reporter” instead of “reporter.”
  • You can use cf.getId() as the first parameter in the InvalidInputException, and it will show up under the custom field – but the label was custom_field_10023 or something like that. Don’t know if there is a way to have it show the field name in the label.
  • You can show errors for multiple fields by creating an instance of InvalidInputException for the first error, and then calling myException.addError(..) for the remaining errors.
  • You can omit the first parameter to InvalidInputException, and just pass in the error message. However, nothing will show up under the field causing the error in this case.
  • All of the examples I found used customFieldManager.getCustomFieldObjectByName, but according to the documentation, that method has been deprecated in favor of customFieldManager.getCustomFieldObjectsByName.

Bootstrap 4 and RequireJS

I’ve been loading Boostrap 3 via RequireJS without issue. My app.js looked like the following:

However, when attempting to load Bootstrap 4, which requires Popper.js, I kept getting the following error from Bootstrap: “Bootstrap dropdown require Popper.js (https://popper.js.org)” Even though Popper.js was included before Bootstrap in my paths, and I added Popper.js as a dependency in the Bootstrap shim

The issue seems to be that Popper.js is never defined in the global scope. In order to get around that, I did the following, which seems to work:

There might be a more elegant way to handle this, but my knowledge with RequireJS is limited. My application compiled (using Grunt) without issue as well. This issue is also supposed to be resolved in an upcoming Bootstrap release. So, this might only be needed temporarily.