Advertisement
icsy7867

Jira Issue Collector - Auto Populate username and email

Jul 28th, 2022
879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!-- Requires jQuery! -->
  2.  
  3. <script>
  4. // Requires jQuery!  
  5. var dispName = $("meta[name='ajs-user-display-name']").attr('content');
  6. var artName = $("meta[name='ajs-page-title']").attr('content');
  7. var spaceName = $("meta[name='ajs-space-name']").attr('content');
  8. var spaceKey = $("meta[name='ajs-space-key']").attr('content');
  9. var currentURL = window.location.href;
  10.  
  11. var bodyText = 'Article URL: ' + currentURL +'\n';
  12. bodyText += "==== Please include details below ====";
  13. var summaryText = "Feedback on Wiki Article: " + artName;
  14.  
  15. // Requires jQuery!
  16. jQuery.ajax({
  17.     url: "https://JiraServerHere.com/plugins/servlet/issueCollectorBootstrap.js?collectorId=8c0e3a2f&locale=en_US",
  18.     type: "get",
  19.     cache: true,
  20.     dataType: "script"
  21. });
  22.  
  23.  
  24. function getCurrentUserName(inVar) {
  25.     var user;
  26.     var emailaddr;
  27.     jQuery.ajax({
  28.         url: "/rest/gadget/1.0/currentUser",
  29.         type: 'get',
  30.         dataType: 'json',
  31.         async: false,
  32.         success: function(data) {
  33.             user = data.username;
  34.             emailaddr = data.email;
  35.         }
  36.     });
  37.     if (inVar == 'username') {
  38.        return user;
  39.     } else if (inVar == 'email') {
  40.        return emailaddr;
  41.     } else {
  42.        return user;
  43.     }
  44. }
  45.  
  46.  
  47.    window.ATL_JQ_PAGE_PROPS = $.extend(window.ATL_JQ_PAGE_PROPS, {
  48.     // ==== custom trigger function ====
  49.     triggerFunction : function( showCollectorDialog ) {
  50.         $('#feedback-button').on( 'click', function(e) {
  51.             e.preventDefault();
  52.             showCollectorDialog();
  53.         });
  54.     },
  55.     // ==== we add the code below to set the field values ====
  56.     fieldValues: {             
  57.         summary : summaryText,
  58.         description : bodyText,
  59.         email : getCurrentUserName('email'),
  60.         fullname : dispName   }
  61.                
  62.     });
  63.  
  64.  </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement