hi all
in the create issue screen there is a field as Watchers, I want to update this field even if the user didn't do it in the creating step. I used following script in scriptrunner post function so that add "b-atb" user to Watcher list :
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
MutableIssue issue = issue as MutableIssue
def myField = customFieldManager.getCustomFieldObjectByName("Watchers")
issue.setCustomFieldValue(myField,'b-atb')
but after publishing, when i tried to create an issue, following message has been shown in the create screen:
We can't create this issue for you right now, it could be due to unsupported content you've entered into one or more of the issue fields. If this situation persists, contact your administrator as they'll be able to access more specific information in the log file.
any advise will be so appreciated
Hi @sahere ,
I suppose You need use startWatching(ApplicationUser user, Issue issue)
Also not sure setCustomFieldValue(myField,'b-atb') it not work because You try set String to Watch field.
To find user You can use DefaultUserManager.
More info
B.R.
Hello @sahere
You are getting the error, because you are treating "watcher" as a custom field and thus gettting error in your logs.
Please use watcher Manager as defined in API
Example code here, please see answer from Henning Tietgens
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.