How to display an info message on a transition screen based on value in customfield?

I have a transition screen with some customfields, one of them is a single select dropdown. If the user selects a specific value in that which matches with another customfield value present on the issues view screen, then I have to display a message on the screen giving a warning but still allowing the user to go through with the transition . How can I achieve this ?

It’s all a simple matter of programming. Let us know how you get on. If you get stuck, post the details here, and we’ll help you out.

Hi David,
I did some finding and used javascript in the customfield description as below

<script type="text/javascript"> 
var e = document.getElementById('customfield_14900'); //target platform field
if(e!=null){

var tplat= e.options[e.selectedIndex].text; //value set in target platform field
var proField = document.getElementById('customfield_11502-val');
if(proField!=null && tplat!=null) {
 

var pro = document.getElementById('customfield_11502-val').innerText;// Platforms Released On field
var proLc = pro.toLowerCase();
var tplatLc = tplat.toLowerCase();


//Initial Pop-up
if (proLc.indexOf(tplatLc) >= 0) {
  alert(getMessage(tplat));
}


e.onchange=function() {
  if(pro!=null) { //happens when you are only on Change API Req Screen
   var newVal = e.options[e.selectedIndex].text;
   if (proLc.indexOf(newVal.toLowerCase()) >= 0) {
    alert(getMessage(newVal));
  }
 }
};

}
}
function getMessage(value) {

var msg = "This API is already released for "+ value +". If you still want to make changes, the 'Platform Released on' field and API version will be reset. You will have to complete the new API change and release the API again.";

return msg;
  
}
</script>

This works.

The initial pop-up displays even before the transition screen comes up(on clicking of the transition button), so I added a setTimeOut(showAlert,1500) . This works, but probably not the best way out. I am novice in javascript, so how can I check if the transition screen has finished loading and then call this popup ?

Do you need to give the user an opportunity to back out of the transition? Does the user have to acknowledge the message? or do you just want to show a message and go ahead with the transition?

It is just an alert to the user, if he/she selects a certain value in the dropdown. They would have to acknowledge it.

The user should be allowed to go ahead with the transition once the pop-up is read.

Got it. I’m going to suggest a different approach, which would eliminate the need for JavaScript intervention during the transition. How about you define a Web Panel that contains the warning message, and maybe an ‘Acknowledge’ button. You could specify a condition so that the web panel would only appear if a) the value selected by the user during the transition matches the other custom field values; and b) the message has not yet been acknowledged. You could store the fact of the acknowledgement in an entity property attached to the issue.

1 Like

I forgot to mention that you’d probably add the web panel to the atl.jira.view.issue.right.context location. See Web Fragments for more information about locations.

Thanks David. I’ll check and see how this works out.