How do I dynamically generate a customer portal issue link?

Fred Gruhn April 28, 2017

Greetings,

I'm using ScriptRunner to create a custom email based on a transition postfunction. 

In the email, I want to generate the URL for the Service Desk customer portal URL for the issue. For example, I want to dynamically generate: http://jira.XXXXX.com/servicedesk/customer/portal/5/SSD-667

When I append ${issue.key} to the end of the above (ending with portal/5/). I recevie an error when trying to access it from the email. 

How can I discern (via ScriptRunner Groovy script) what numeric value needs to come aftrer /portal/? 

2 answers

1 vote
Thanos Batagiannis _Adaptavist_
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.
May 12, 2017

Hi Fred, 

In order to get the portal id via the service desk api use the below script

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.ServiceDeskManager
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

@WithPlugin("com.atlassian.servicedesk")

@PluginModule
ServiceDeskManager serviceDeskManager

def project = ComponentAccessor.getProjectManager().getProjectByCurrentKey("TB")
def portalId = serviceDeskManager.getServiceDeskForProject(project).right().get().id

Let me know if this does the trick.

regards Thanos

Fred Gruhn May 12, 2017

Thanos,

Thanks for the reply. When I paste your submission into the "Condition and Configuration" script window for the Custom Email page, I get the following error on line 12 (last line of your submission): 

[Static type checking] - no such property: id for class: R @ line 12, column 16. 

0 votes
Martina Riedel
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.
August 21, 2020

This works with JSD 4.5.5

import com.atlassian.servicedesk.api.ServiceDeskManager
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

@WithPlugin("com.atlassian.servicedesk")

@PluginModule
ServiceDeskManager serviceDeskManager

def project = issue.getProjectObject()
def portalId = serviceDeskManager.getServiceDeskForProject(project).getId()

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events