Problem setting Component Lead during post function script

I'm intend to update the component lead during runtime. I'd created a post function script to perform the following:

import com.atlassian.jira.bc.project.component.ProjectComponent;
import com.atlassian.jira.bc.project.component.MutableProjectComponent;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.bc.project.component.ProjectComponentManager

long pid = ComponentAccessor.getProjectManager().getProjectObjByKey("XXXX").getId();
ProjectComponentManager projectComponentManager = ComponentAccessor.getProjectComponentManager();
ProjectComponent existingComponent = projectComponentManager.findByComponentName(pid, "YYYY");
MutableProjectComponent newComponent = MutableProjectComponent.copy(existingComponent);
newComponent.setName("NAME");
newComponent.setDescription("DESC");
newComponent.setLead("PERSON");
projectComponentManager.update(newComponent);

Observed that the user name did not populate and update correctly (shown as '?' on the Project -> Component Screen).

Same script had been trigger on the Script Console and it works just fine.

Any idea what was the problem?

3 answers

1 accepted

Hi Jamie,

I'd found the problem, user id imported from AD are being converted and cache as lower case by default.

I just added .toLowerCase() on the new Lead and it solved the problem.

Thanks for your help. :)

0 vote

If it works from admin console it should work from a post-function. Are all the parameters definitely the same?

Hi Jamie,

Thanks for the response. I'd tested a few rounds and noticed that by setting the Lead Name to a user id from our Active Directory, it ended the results as "User does not exist".

but if i set it to a JIRA user from JIRA internal directory, it seems being set correctly.

Any idea what could went wrong?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

189 views 1 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you