How do I dynamically generate a customer portal issue link?

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/? 

1 answer

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

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. 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

182 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you