Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Add user to CC list with create issue post function

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 am trying to add user to cc list using groovy thru Create Issue Post function. I tried setting with watcherManager but I am getting GenericEntityException, JIRA is 6.2.2 and MySql db

try{
WatcherManager watcherManager = ComponentAccessor.getWatcherManager();
watcherManager.startWatching(jiraUser, issue);
}catch (GenericEntityException e){
	log.error("There was an error adding user to CC List", e);
}
2015-07-31 11:50:41,775 http-bio-8080-exec-16 ERROR 710x24692x1 1qhnf2i 10.67.65.9,10.15.160.174 /secure/QuickCreateIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] ************************************************************************************* 2015-07-31 11:50:41,776 http-bio-8080-exec-16 ERROR 710x24692x1 1qhnf2i 10.67.65.9,10.15.160.174 /secure/QuickCreateIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: null, actionId: 1, file: /opt/export/jira/groovy/PostFunction_SetAssignee.groovy com.atlassian.jira.exception.DataAccessException: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:UserAssociation][sinkNodeId,null][created,2015-07-31 11:50:41.765][associationType,WatchIssue][sourceName,jrubio][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 com.atlassian.jira.association.UserAssociationStoreImpl.createAssociation(UserAssociationStoreImpl.java:67)         at com.atlassian.jira.association.UserAssociationStoreImpl.createAssociation(UserAssociationStoreImpl.java:46)         at com.atlassian.jira.issue.watchers.DefaultWatcherManager.updateWatch(DefaultWatcherManager.java:206)         at com.atlassian.jira.issue.watchers.DefaultWatcherManager.updateWatch(DefaultWatcherManager.java:193)         at com.atlassian.jira.issue.watchers.DefaultWatcherManager.startWatching(DefaultWatcherManager.java:59)         at com.atlassian.jira.issue.watchers.WatcherManager$startWatching.call(Unknown Source)         at PostFunction_SetAssignee.run(PostFunction_SetAssignee.groovy:54) Caused by: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:UserAssociation][sinkNodeId,null][created,2015-07-31 11:50:41.765][associationType,WatchIssue][sourceName,jrubio][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:200)         at org.ofbiz.core.entity.GenericDAO.insert(GenericDAO.java:165)         at org.ofbiz.core.entity.GenericHelperDAO.create(GenericHelperDAO.java:83)         at org.ofbiz.core.entity.GenericDelegator.create(GenericDelegator.java:554)         at org.ofbiz.core.entity.GenericDelegator.create(GenericDelegator.java:540)         at org.ofbiz.core.entity.GenericValue.create(GenericValue.java:98)         at com.atlassian.jira.association.UserAssociationStoreImpl.createAssociation(UserAssociationStoreImpl.java:63)         ... 6 more

 

I tried other way setting CC list custom field but this is also not working

CustomField ccListCustomField = customFldMgr.getCustomFieldObjectByName("CC List");
def users=issue.getCustomFieldValue(ccListCustomField);
if(users == null){
	users = new ArrayList<User>();
}
users.add(jiraUser);
mi.setCustomFieldValue(ccListCustomField , users);

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
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.

TAGS
AUG Leaders

Atlassian Community Events