Forums

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

Error when trying to add watchers to issue in with Scriptrunner built-in postfunction

Adolfo Casari
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.
February 6, 2014

I am using create subtask ScriptRunner PostFunction (latest version of the plugin).

All works OK, except when I try to add watchers to the newly created SUBTASK.

As part of the Additional Issue Actions I have:

//Add watchers
log.debug("Add Watchers")
ProjectRole role3 = roleManager.getProjectRole("Satelital_Watchers")
ProjectRoleActors actors3 = roleManager.getProjectRoleActors(role3, myProject)
Set<ApplicationUser> users3 = actors3.getApplicationUsers()
users3.each {ApplicationUser user ->
watcherManager.startWatching(user, issue)
}

but this causes an SQL Exception (This is JIRA 6.1.7 and DB is MySQL):

Caused by: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:UserAssociation][sinkNodeId,null][created,2014-02-06 18:38:11.01][associationType,WatchIssue][sourceName,sebastian.gonzalez][sinkNodeEntity,Issue] (SQL Exception while executing the following:INSERT INTO userassociation (SOURCE_NAME, SINK_NODE_ID, SINK_NODE_ENTITY, ASSOCIATION_TYPE, SEQUENCE, CREATED) VALUES (?, ?, ?, ?, ?, ?) (Column 'SINK_NODE_ID' cannot be null))
	at org.ofbiz.core.entity.GenericDAO.singleInsert(GenericDAO.java:158)
	at org.ofbiz.core.entity.GenericDAO.insert(GenericDAO.java:123)
	at org.ofbiz.core.entity.GenericHelperDAO.create(GenericHelperDAO.java:64)
	at org.ofbiz.core.entity.GenericDelegator.create(GenericDelegator.java:503)
	at org.ofbiz.core.entity.GenericDelegator.create(GenericDelegator.java:483)
	at org.ofbiz.core.entity.GenericValue.create(GenericValue.java:98)
	at com.atlassian.jira.association.UserAssociationStoreImpl.createAssociation(UserAssociationStoreImpl.java:63)

Problem is sinkNodeId being null.

Any ideas what is wrong?

1 answer

1 accepted

0 votes
Answer accepted
Adolfo Casari
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.
February 6, 2014

Actually this was not the right place to add watchers.

I moved the function to the SUBTASK workflow postfunction (after the create issue) and now it works OK.

srinivasp
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.
July 31, 2015

Hi Adolfo, I am facing same issue. Is there a way to fix this issue with parent issue post function adding users to watchers?

srinivasp
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.
July 31, 2015

I moved the my post function next to "Creates the issue originally" step and it started working.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events