Forums

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

Add a new entity to an existing notification scheme via Scriptrunner

Mike Schultz
Contributor
March 24, 2021

Hello. I am looking for an example Scriptrunner script for adding a new entity to a notification scheme in Jira. I need to add a new entity to a lot of notification schemes and everything I have tried is far from complete.. Hoping someone has an example on hand.

Thanks in advance!

1 answer

0 votes
Nic Brough -Adaptavist-
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 Leaders.
March 25, 2021

By "entity" do you mean a (type of) recipient, or a new event?

To explain that a little, each row of a notification scheme, in plain English says:

When <an event of type x> arrives, send an email about it to <a set of people defined by...>

So I'm asking if your "entity" means an event or a set of people?

Mike Schultz
Contributor
March 25, 2021

@Nic Brough -Adaptavist- I am hoping to add a user picker custom field to an existing scheme/entitytypeId (issue created)

I was attempting to build an entity object and then add it to the Scheme but I may have been going about it the wrong way. I did find the "swap entity parameters" method but that only works if the parameter type is already existing in the entity. 

Using your example, I want:

When an event of typeId 2 arrives, send an email about it to the users within a user picker custom field.

Nic Brough -Adaptavist-
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 Leaders.
March 25, 2021

So that does not tell me what "entity" means.  To be blunt and grumpy about it, a notification scheme has "Events" and "People to tell", there's no "entity" mentioned.  The middle paragraph does not work for me.

But the first and last paragraphs really do work for me, they're crystal clear.

On the first paragraph:  "I am hoping to add a user picker custom field to an existing scheme/entitytypeId (issue created)".  You can do that.  In the notification scheme, find "issue created" and then add "custom field -> <your user picker custom field>" to it

On the last one "When an event of typeId 2 arrives, send an email about it to the users within a user picker custom field" - find the event to notify people on and, as the one above, add the user picker custom field as one of the rules to notify people about on that event.

Note - I have a nagging doubt that we've not mentioned events much - have you added some custom events and then added them to workflows (if not, then did you mean to?) and then used them in notifications?

Mike Schultz
Contributor
March 26, 2021

@Nic Brough -Adaptavist-

My overall goal is stated fairly clearly in my last comment:

I am hoping to add a user picker custom field to an existing scheme/entitytypeId (issue created) using a scriptrunner script. This would be via the API, which does contain Schemes, Entities, etc. as I mentioned. 

It seems as though the response received has convoluted this. Please provide an example if you have a script on hand, if not, I am hoping another member of the community has one. 

Nic Brough -Adaptavist-
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 Leaders.
March 26, 2021

I'm afraid that makes it even worse.  I cannot work out what you're trying to do at all from that.

I'm going to guess that what you're trying to do is either

  • Add data to an issue
  • Add a field to a project or issue type in the configuration 

Is it one of those two?  If not, then can you tell us what you're trying to do without talking about entities, apis or any of the internals, just explain what changes for the end-user as a result of doing it.

(What I suspect has confused me here is the references to notifications and emails - they have nothing to do with fields directly, and I've been trying to chase down what you mean by "add entity to notification scheme")

Mike Schultz
Contributor
March 27, 2021

Here is a picure @Nic Brough -Adaptavist- . I want to add a user custom field to a Notification scheme systematically. 

Capture.PNG

Nic Brough -Adaptavist-
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 Leaders.
April 18, 2021

I am sorry, I have missed the update email on this conversation.

That is perfectly clear, you want to update a scheme somehow (with a supported value, not going to say "no" to that)

Scheme edits are admin actions, and Jira is not yet exposing all its admin actions remotely so either we need to do it inside Jira or wait until we get the remote option.  

Scriptrunner, and other things (I don't look any more, Adaptavists get to use SR everywhere, but it's not fair to assume anyone has SR, or that there are not other routes) can update your scheme.

But I can't find any script that does it, so I'm a bit stuck.  I know it can, but I do not know how.

Suggest an answer

Log in or Sign up to answer