I am trying to fetch email addresses of stakeholders field and use it to send email to them. However I could not find a way to do so.
Hi @Sidra Shakoor ,
Yes, you can fetch stakeholder email addresses only if the Stakeholders field is an Assets (Object reference) field and the referenced object contains an Email attribute.
Jira cannot automatically read email addresses from a Stakeholders field unless the email is explicitly stored on the Assets object. If your object type (for example, Person or Employee) has an Email attribute, you can use it in automation like this:
{{issue.Stakeholders.Email}}
If the field allows multiple stakeholders, use:
{{issue.Stakeholders.Email.join(",")}}
If the Assets object does not have an Email attribute, it is not possible to fetch or send emails from the Stakeholders field. In that case, you must either add an Email attribute to the Assets schema or use a Jira User Picker field instead.
Sorry I forgot to mention that I was referring to Services Object (Which is built-in). In that One can not add or delete any attribute. Is that possible to fetch email of the stakeholder in that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for clarifying. Since you’re referring to the built-in Services object in JSM (Operations/Services), the answer is no — it’s not possible to fetch stakeholder email addresses from it.
The built-in Services object is read-only. You can’t add, modify, or expose attributes like email addresses, and the Stakeholders linked to a Service are not available as user/email fields in Jira Automation or REST APIs.
Because of this limitation, Jira cannot fetch or use stakeholder emails from Services for notifications.
If emailing stakeholders is required, the only supported options are:
Maintain stakeholders as Assets Person/Employee objects with an Email attribute, or
Use Jira User Picker fields instead of Services
Unfortunately, with the built-in Services object alone, this isn’t supported today
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Sidra Shakoor
This is not an area I'm very familiar with. Can you confirm for me that you are talking about the Stakeholders field in the Services that are listed under the Operations area for a JSM Cloud project?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Assuming I am looking at the same thing you are...
What I've learned so far:
If I use an API call like this to see all the fields in a JSM project where the Affected Services field has been set:
https://mysite.atlassian.net/rest/api/2/issue/TCSMC-1?expand=names
...I find that the Affected Services field corresponds to a custom field ID that stores information in the issue like this:
"customfield_10241": [
{
"id": "ari:cloud:graph::service/3754298e-7592-11ea-8733-0a77f3f45304/e93eaaa6-2d87-11ee-8c1d-0abe3f4a6601"
},
{
"id": "ari:cloud:graph::service/3754298e-7592-11ea-8733-0a77f3f45304/f0106fe6-da09-11f0-9fa7-122fa60ab53d"
}
],
So it doesn't seem like the Stakeholder field for the Service is directly available within the issue.
I found a couple of things that may be relevant:
https://jira.atlassian.com/browse/JSDCLOUD-9912
This is a suggestion to about revealing more information about Affected Services in the issue API. It includes a work around for getting the Service Name and Tier using the GraphQL API.
I also found that when I added a new Service that an Asset Object was created in a Asset Schema named Services.
If you can get the Service Name with the GraphQL API, then you could potentially use the Assets API to retrieve the underlying Object ID, and then use that to retrieve the Stakeholders attribute to get identifying information about the Stakeholder(s).
I haven't tried to actually work through this. At a glance it seems a bit complicated. Maybe somebody else has an easier way to get the information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I discovered more information I wanted to share here.
If you are selecting those Services through the Affected Services field in your JSM items there are some pieces of information you can get about those services, but unfortunately not the Stakeholders.
Refer to:
However...
Since you can get the Service Name, you can then use that in a Lookup Objects action to get the Object(s) with that Name from the Services Schema.
You can then get the User Id(s) in the Stakeholders attribute of the object.
{{lookupObjects.Stakeholders}}
Unfortunately you can't then directly get the user email address. There is a change request to expose that:
https://jira.atlassian.com/browse/JSDCLOUD-10088
But, you could use the user ID you got to look up the user using the REST API and a Send Web Request action.
https://yourBaseURL/rest/api/3/user/search?accountId={{lookupObjects.Stakeholders}}
The last caveat though is depending on the user's privacy settings their email address my not be returned.
In the above case I did not provide any authentication information in the header so the API was called anonymously. And the provide of the user I queried has the privacy setting so that the email will not display. So the email address was not included in the web response even though it did successfully retrieve the user information otherwise.
If you are authorized for User Management you might be able to use this other API to get the user information including email:
You would have to parse the {{webResponse.body}} to extract the email addresses.
I experimented with this with a JSM item that had just one Service selected in Affected Services, and where that Service had just one Stakeholder.
If the work item had multiple Services selected, or multiple Services objects had the same name, or there were multiple Stakeholders associated with the resultant objects, then the rule gets a bit more complicated to parse data from the multi-valued results.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I assume that the stakeholders field in assets u are referring is an Attribute in objects in Assets.
If its a single people select use {{stakeholders.Email}} use the exact name u have named the attribute
Hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry I forgot to mention that I was referring to Services Object (Which is built-in). In that One can not add or delete any attribute (That's the built-in fields too). Is that possible to fetch email of the stakeholder in that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Trudy Claspill is correct, i did some checking also and i managed to get the stakeholders user id
so i believe u can get it by making a GET web request inside automation
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I believe better way would be, to make look up table Services Vs Stakeholder emails and then send them emails for any notification if change in service.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately the down side of this design would be that any changes to the list of stakeholders for a service would have to be made in two places.
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.