Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Java script Implementation

Sushma Nagaraj September 14, 2018

Hello Team,

I have a Java script which works pretty well except for the case when a issue create pop up screen appears. It works for this case too but after I have opened the pop up screen two times, it starts pre populating the field value the third time I open the create pop up window, any idea as to how I could make changes to the code so that it works the very time I open the create pop up window.

 

 

<script type="text/javascript">
(function($) {
 // This is for when an issue is being created while
// opened in a new window tab
 AJS.toInit(function(){
 if (AJS.$("#issue-create-submit").val()=="Create" // || AJS.$("#create-issue-submit").val()=="Create"
  ){
  var issuetype=AJS.$("#issue-create-issue-type").text();
  if(issuetype=="Task"){
  $(document.getElementById("customfield_14041")).change(function(){
   
   switch ($(document.getElementById("customfield_14041")).val()) {
        case "23125":
          AJS.$("#assignee-field").val("Sushma.nagaraj");
        break;
        default:
          AJS.$("#assignee-field").val("Sushma.nagaraj");
      }
     });
}
 
 }
 });// This is when issue is being created via dialog box popup.
 //AJS.$(document).ready(function() {
 JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
 if (
    // AJS.$("#issue-create-submit").val()=="Create" ||
    AJS.$("#create-issue-submit").val()=="Create"){
  var issuetype=AJS.$("#issuetype-field").val();
  if(issuetype=="Task"){
  $(document.getElementById("customfield_14041")).change(function(){
   
   switch ($(document.getElementById("customfield_14041")).val()) {
        case "23125":
          AJS.$("#assignee-field").val("Sushma.nagaraj");
        break;
        default:
          AJS.$("#assignee-field").val("Sushma.nagaraj");
      }    });}
 }
 });})(AJS.$);
</script>

1 answer

0 votes
Gonchik Tsymzhitov
Community Champion
September 14, 2018

Hi! 

I am using jsincluder, this app help me forget a lot event listeners and so on.

https://marketplace.atlassian.com/apps/1211670/jsincluder

 

 

hope it helps you also:)

Because you can in related screen and action.

 

Cheers,

Gonchik Tsymzhitov

Sushma Nagaraj September 14, 2018

Hello Gonchik,

The jsincluder looks really cool. But I would like some manipulations to the existing code itself because we already have a lot of add ons and we may slow down the system having a few more.

Gonchik Tsymzhitov
Community Champion
September 15, 2018

Hi! 

Could you extend listener condidtion? (INLINE_EDIT_BLURRED

https://developer.atlassian.com/server/jira/platform/extending-inline-edit-for-jira-plugins/

 

Cheers,

Gonchik Tsymzhitov

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events