Forums

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

How i can setup delay before postFunction? Or add watchers how issue create(postfunction)?

Ruslan February 8, 2023

Guys,Hi. I have custom script, that adds and deletes watchers, depending on the transition. It work great, but i can't add watcher when issue created, first step.  Only first, another work great.

I have error: 

2023-02-09 09:24:28,400 ERROR [workflow.AbstractScriptWorkflowFunction]: Workflow script has failed for user ''. View here: https://ji/secure/admin/workflows/ViewWorkflowTransition.jspa?workflowMode=live&workflowName=Software+Simplified+Workflow+for+Project+ED&descriptorTab=postfunctions&workflowTransition=1&highlight=1 java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:877) at com.google.common.cache.LocalCache$LocalManualCache.invalidate(LocalCache.java:4898) at com.atlassian.jira.issue.watchers.DefaultWatcherManager.updateWatch(DefaultWatcherManager.java:175) at com.atlassian.jira.issue.watchers.DefaultWatcherManager.startWatching(DefaultWatcherManager.java:92) at com.atlassian.jira.issue.watchers.DefaultWatcherManager.startWatching(DefaultWatcherManager.java:83) at com.atlassian.jira.issue.watchers.WatcherManager$startWatching$0.call(Unknown Source)

 

I read that the issue has not been created yet, so I can't add it. Will delay help me? and how to make it?

 

Yes,i know,i can use listener, but i want do all in postfunction 1 file. 

1 answer

1 accepted

3 votes
Answer accepted
Alex Koxaras _Relational_
Community Champion
February 8, 2023

Hi @Руслан 

If you use a post function then this is running after the transition happens. Try to move your post function on the final slot (below "fire a listener"). Try that and let me know if this works.

Ruslan February 8, 2023

Hi, @Alex Koxaras _Relational_  honestly, i dont undestend, what i need to do. 

If you can, say more for small example. 

 

my code :

import com.atlassian.jira.component.ComponentAccessor

def userManager = ComponentAccessor.getUserManager()
def user = userManager.getUserByName("test@test.ru")
def watcherManager = ComponentAccessor.getWatcherManager()
watcherManager.startWatching(user, issue)

 

 

workflow.PNG

Alex Koxaras _Relational_
Community Champion
February 8, 2023

@Руслан 

On the transition you are pointing with the arrow, once you click it, a pop up will appear. Click on "post function" and then move your post function on the end of the list:

click post function.png

move last.png

Ruslan February 8, 2023

@Alex Koxaras _Relational_ thanks a lot, now its working. 

Like Kelly Arrey likes this

Suggest an answer

Log in or Sign up to answer