I've been trying add shared-with customers to my service desk issue with the following code which seems to work but doesn't seem to add the users to the "Shared with" list on my portal. What am I missing?
The goal is to add all of the approvers to the shared-list so they can see the ticket details.
Here's the code I'm using in the script runner for now:
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.loader.ActionDescriptor
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.plugins.share.ShareService
import com.atlassian.jira.plugins.share.ShareBean
def issueManager = ComponentAccessor.getIssueManager()
def workflowManager = ComponentAccessor.getWorkflowManager()
def issueService = ComponentAccessor.getIssueService()
def userManager = ComponentAccessor.getUserManager()
@WithPlugin("com.atlassian.jira.jira-share-plugin")
@PluginModule
ShareService shareService
def issue = issueManager.getIssueByCurrentKey("abcd-36")
Set<String> userkeys = Collections.singleton("flast")
Set<String> emails = Collections.emptySet()
String message = "Welcome to my ticket"
def shareBean = new ShareBean(userkeys, emails, message, null)
def validateResult = shareService.validateShareIssue(autoUser, shareBean, issue)
if (!validateResult.isValid()) {
log.error "Failed to validate Share Issue parameters:\n${validateResult.errorCollection}"
return null
}
shareService.shareIssue(validateResult)
log.info(autoUser.displayName + " is sharing " + issue.key + " with " + userkeys)
Does service desk use a different shared-with mechanism? Can I control it programmatically?