I am trying to get the email address of reporter for JIRA HELP DESK 2.0
I have JIRA 6.3.6 and I use "Script runner"
Here my script :
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.component.ComponentAccessor //IssueManager issueManager = ComponentManager.getInstance().getIssueManager(); //Issue issue = issueManager.getIssueObject("ST-1799"); ComponentManager componentManager = ComponentManager.getInstance() CustomFieldManager customFieldManager = componentManager.getCustomFieldManager() CustomField email = customFieldManager.getCustomFieldObjects(issue).find {it.name == "Email"} MutableIssue myIssue = issue def reporterEmail = myIssue.getReporter().getEmailAddress() myIssue.setCustomFieldValue(email, reporterEmail)
This script work only for user and not for "customer"
I think that "getEmailAddress()" comes from "crowd API" and customer is not in crowd but in JIRA DIRECTORY...
Any workaround to fix this ?
Do you know other way to get Email address ?
Thank you very much.
Community moderators have prevented the ability to post new answers.
User.getEmailAddress()
should return the mail address for all kind of users, regardless if they come from Crowd or not. How exactly does that script not work? Do you get an error message? Is the "Email" custom field just not set?
Maybe the user really does not have a mail address set. Did you check that?
What do you mean with "customer"? Is that a special user?
Maybe the user really does not have a mail address set. Did you check that?
I did it
Do you get an error message?
No
What do you mean with "customer"? Is that a special user?
I use JIRA HELP DESK 2.0 and It manage customer and agent, customer could not be an user (no licence), It's a restrited user. He cannot choose their prefered language (example)
The script work when I create an issue with a user but not for a customer who is not a user (he has no licence)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, then customers are not JIRA users and therefore you cannot get the mail address like that. Sorry, I don't know how to do it for JIRA Service Desk 2.0.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
for anyone that reads this, probably you can get the customer email for another issue fields such as reporter por example, as customers are indeed created as clients of the project and most of the issues are created by them, always having in mind that they are registered users if not you can use a mandatory custom field when creating the issue to register email for public portals, so yo can access it an use it as needed.
For registered customers of the client portal, Test this sentences in the Scriptrunner console to display all issue structure:
Note: obviously issuekey should be (def issueKey = "test-0001" --> your issue id)
def currentIssue = get('/rest/api/3/issue/' + issueKey)
.asObject(Map)
return currentIssue
Inside the body you will found the subdictionary "creator" where all information could be found.
Having this, you can now use any other Jira Api endpoint to keep going.
Hope it helps
Kind regards
Alberto Elvira Galindo - Papyrum
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.