Forums

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

Retrieve Full Name from an Actors Project Role

Daniel Burke
January 18, 2018

I need to retrieve an project Actors Full Name (i.e Bob Smith), when iterating over project roles.

Currently I am able to use:

//Gets all of the projects, along with project roles (i.e. "developer" + username and full name, i.e. bed2scp Daniel Burke ENGIT_Developer)
for(Project projectarray in projectArray){
for(ProjectRole projectrole in projectRoles){
def actorRole = projectRoleManager.getProjectRoleActors(projectrole, projectarray)
//projectLead = projectarray.getProjectLead()

if(actorRole.getUsers().toArray().size() >= 1){
log.error("\r\n" + projectarray.getKey() + "_" + projectrole.getName() + "=" + actorRole.getUsers().toArray() + "" + "\n" + "\r\n")

However, this only retrieves the users username i.e. bed2scp 

Ideally I would like to have both like: bed2scp Daniel Burke 

I tried to use:

//Gets all of the projects, along with project roles (i.e. "developer" + username and full name, i.e. bed2scp Daniel Burke ENGIT_Developer)
for(Project projectarray in projectArray){
for(ProjectRole projectrole in projectRoles){
def actorRole = projectRoleManager.getProjectRoleActors(projectrole, projectarray)
//projectLead = projectarray.getProjectLead()

if(actorRole.getUsers().toArray().size() >= 1){
log.error("\r\n" + projectarray.getKey() + "_" + projectrole.getName() + "=" + actorRole.getUsers().toArray() + actorRole.getDisplayName() + "" + "\n" + "\r\n")

But this method is not valid.

 

Please help!

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Danyal Iqbal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 23, 2018

this is not allowed .

How do you trigger the execution?

Add the directory to your script roots-https://scriptrunner.adaptavist.com/latest/jira/#_script_roots

Try the import with "@WithPlugin" directive e.g

@PluginModule
AllPublicStructureComponents structureComponents

// Specify that classes from this plugin should be available to this script
@WithPlugin("com.atlassian.jira.plugin.devstatus.impl.DefaultDevStatusSummaryService")
ralfeus
Contributor
April 23, 2018

What is not allowed? Using plugins in script?

So far I don't trigger the execution but start the script manually. In the future I'm going to run it as a post-function in workflow status transition.

Try the import with "@WithPlugin" directive e.g

 I tried. The result was a bit different but the error was same:

unable to resolve class com.atlassian.jira.plugin.devstatus.impl.DevStatusSummaryService @ line 4, column 1. @WithPlugin("com.atlassian.jira.plugin.devstatus.impl.DefaultDevStatusSummaryService")

Danyal Iqbal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 24, 2018

@WithPlugin("enter plugin.key here")

Find the key here: Manage addons>select plugin>addon key.

This annotations only work when running a script that is under a script root (the script directory is teh script root by default. place your script there)…​ not a script outside a script root, nor code pasted into the console.

What is not allowed?

Your approach to import another plugin in your script.

ralfeus
Contributor
April 24, 2018

Yeah, you're right about @WithPlugin annotation.

Still if I comment "import" clause out I can run the script from script console (it accesses branches and pull requests of the issue). So it seems it's possible to access plugins from console scripts. How can it be?

Danyal Iqbal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 24, 2018

+1 for

How can it be?

You should create a support request to report unexpected behaviour. They should be able to explain it away. I am also curious.

ralfeus
Contributor
April 25, 2018

Ok, thanks. 

Created a request to Adaptavist https://productsupport.adaptavist.com/servicedesk/customer/portal/2/SRJSUP-4549

Let's see what they say

ralfeus
Contributor
April 25, 2018

Actually even when running from file it gives same error:

2018-04-25 16:04:09,172 WARN [common.UserScriptEndpoint]: Script console script failed: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: file:/var/atlassian/application-data/jira/scripts/test.groovy: 4: unable to resolve class com.atlassian.jira.plugin.devstatus.impl.DefaultDevStatusSummaryService @ line 4, column 1. @WithPlugin("com.atlassian.jira.plugins.jira-development-integration-plugin") ^ 1 error

Like hahamei likes this
TAGS
AUG Leaders

Atlassian Community Events