Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
//Go through each address in ccAddresses
    for(var i = 0;i < ccAddresses.length; i++)
 
  {
  
     //determine is email address is a jira user.
   
    var emailAddress = ccAddresses[i].getAddress();
        print("[" + emailAddress + "] detected email address");
        var jiraUser = jemhUtils.getUserByEmail(emailAddress);
    
    if(jiraUser == null)

       {
            print("["+ emailAddress + "] was not an email address related to a Jira User");
        }
  
     else
   
    {
   
        print("processing email and attempting to find related users");
     
        
          //get current project use your own project id here.
            var project = jemhUtils.getProjectContext(10300).getProjectObject();
   
        print("["+project.getName()+"] Project Found");
        
                //get required project role use your own project id here.
            var projectRole = projectRoleManager.getProjectRole(10101);
            print("["+projectRole.getName()+"] Project Role Found");
       
    
        //check if the user is in the role  
   
        var isInProjectRole = projectRoleManager.isUserInProjectRole(jiraUser, projectRole, project);

           print("Is user in the Project Role"+"["+projectRole.getName()+"] returned ["+isServiceDeskTeamRole+"]");
        
                //user is in the role then add them to watcher
            if(isInProjectRole)
            {
                print("["+ emailAddress + "] will be added to watchers");
                resultMap.put("watchers", jiraUser.getUsername());
 
          }
            //Any other Jira user is added to request participants 
            else
   
        {
   
            print("["+ emailAddress + "] will be added to request participants");

               resultMap.put("Request participants", jiraUser.getUsername());
            }
    }
   }
    }

Outcome

The result of this example script is that if a non-jira user is found then it will be logged in the report. However if a
Jira user is found then:

...