I have a custom field (project picker) and I want to grab the project lead of the selected project in that field. From that field I figured I could use the project KEY to search and grab the project lead. I have the project key, but I'm having a hard time finding a starting point for using that to search grab the project lead. Any advice?
Thanks,
Tim
Hello,
You could use
ComponentAccessor.getProjectManager().getProjectObjByKey("projectkey").getProjectLead()
Is there a way to use a variable instead of the actual project key? I was trying the code below, but it doesn't seem to work. Cannot invoke method getProjectLead() on null object
def np =customFieldManager.getCustomFieldObjectByName("Needed Project")
def npval = issue.getCustomFieldValue(np)
def text = npval.toString()
String newString = text.replaceAll("Project: ", "")
def project = ("\""+newString+"\"")
def lead = ComponentAccessor.getProjectManager().getProjectObjByKey(project).getProjectLead()
And thanks so much you have been super helpful!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the project variable must equal to the project key. For example, KEY. In your case I guess it is something else. Could add log.error("project: " + project) and paste here the output in atlassian-jira.log file?
def np =customFieldManager.getCustomFieldObjectByName("Needed Project")
def npval = issue.getCustomFieldValue(np)
def text = npval.toString()
String newString = text.replaceAll("Project: ", "")
def project = ("\""+newString+"\"")
log.error("project: " + project)
def lead = ComponentAccessor.getProjectManager().getProjectObjByKey(project).getProjectLead()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much! That got me to see the issue. I think it was the quotes I was adding to "newString". I took out project and put in newString ( getProjectObjByKey(newString) ) and it returned the project lead.
Thanks again,
Tim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.