It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Groovy - How to open an url ?

Rambo Jul 24, 2016

Hello,

I try to open an url in a post-function with a transition in a JIRA workflow. When the user execute a certain transition, I want to open an url "Create issue" with some field filled (with the url).

I tried this code :

import com.santaba.agent.groovyapi.http.*;

def response = HTTP.get("https://www.google.fr/");
println response

But it displays the Error alert :

Error

No such property: HTTP for class: Script405

groovy.lang.MissingPropertyException: No such property: HTTP for class: Script405 at Script405.run(Script405.groovy:3)
Have you an idea why the code is not working ?
Thanks

2 answers

0 votes
Nic Brough [Adaptavist] Community Leader Jul 24, 2016

By "open a url", do you mean you're trying to make the user's browser open a window there?  Or that the post-function is trying to scrape data out of the url to be used later in the script?

Rambo Jul 24, 2016

The first one for now, I try to open a new windows (maybe more a new tab in my actual window) with an already created url (which not change).


Maybe later I'll try to take some information in the issue to fill other fields in the new issue opened.

Thanks for your answer.

Nic Brough [Adaptavist] Community Leader Jul 24, 2016

Ah, ok, I was afraid of that

Post-functions do not have any interface with the client front end.  They run entirely on the server, and what you're trying to do is get the client to do something.  So the short answer is that you can't do it. 

You really need to do it on the front end with some javascript in the UI, but I've never seen that work (even when it has done the basics - javascript picking up changes when returning to the view screen, it failed when processes are automated, done over REST or when add-ons/applications provide more ways to change a status)

Rambo Jul 24, 2016

Ok thanks Nic.

The solution I find is putting a field with my url in the issue view. It opens the new issue in a new tab, as I want, but it's not very visually good for my users.

But if a better solution exists I would be happy to hear it. ^^

Noga Epstein Sep 25, 2016

Hi Rambo,

Can you explain what did you do and add the code?

Thanks,

Noga.

Nic Brough [Adaptavist] Community Leader Sep 26, 2016

They've bodged in a horrible javascript hack which breaks the UI.  Don't do it.

0 votes
testuser Jul 12, 2017

I have found this function:

def baseURL = ComponentAccessor.getApplicationProperties()getString(APKeys.JIRA_BASEURL)
            String jiraBaseUrl = ComponentAccessor.applicationProperties.getString(APKeys.JIRA_BASEURL)
            String clonedMessage = """
                Navigating to created issue <a href="$jiraBaseUrl/browse/$uatIssue.key">$uatIssue.key</a>...
                <script>
                    setTimeout(function(){location.href="$jiraBaseUrl/browse/$uatIssue.key"} , 3000);
                </script>
                """

            UserMessageUtil.success(clonedMessage)

It does work for me. 

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

8,157 views 25 36
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you