Get issue URL on created issue

Answered

Hello,

I'm doing a workflow that notify by email on creation of an issue.

I would like to include the URL of the issue in this email using the "issue.getURL()" method.

When my user create an issue and try to add his email address to the EmailAddress custom field, he sees the following error message :

"Workflow send-email-on-issue-creation reports error: Can't get url for an issue that is not reported
Contact project admin John DOE"

Could you help me ?

0
7 comments
Official comment

The error that you see indicates that you can't get an ID of an issue until it is reported. We recommend to change your workflow to be triggered on `issue.isReported()` instead to ensure that issue exists and you can get its ID.

Please let us know if you have any further questions, we'll be happy to help.

Hi.

When issue created from agent (Web interface) issue.isReported() worked correctly and process workflow triggered with bool. But when issue created by email issue.isReported() didn't work (i.e. bool isReported() is changed, but code within trigger not running as "from agent")

0

Hello Losandreas, could you please clarify your question and attach your code as an illustration? Thanks.

0

Hello, thanks for your answer.
At first main task is - one time (when issue created or comment added) do something with api in new issue or comment. Because of that I do api request when issue creating.
I tried different methods (isReported(), becomesReported() etc.) 2 code texts for example:

1. becomesReported()

when becomesReported() {
  info("\r\nGU isreported - " + issue.isReported() + "\r\nGU becomesreported - " + issue.becomesReported());
  addHttpHeader("Content-Type", "text/html");
  addHttpHeader("Authorization", "Basic *******");
  info("\r\n" + doHttpGet(("http://youtrack:9999/rest/issue/" + getId())));
}

Logs are:
a). from agent (Web-interface)

21 jul 2017 13:03:27,309 INFO  [z->issue create z   ] [tp55562178-1087] [issue create z] [admin@192.168.0.1]
GU isreported - true
GU becomesreported - true
21 jul 2017 13:03:27,324 INFO  [z->issue create z   ] [tp55562178-1087] [issue create z] [admin@192.168.0.1]
HTTP/1.1 404 Not Found
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><error>Issue not found.</error>

b). from email

21 jul 2017 13:05:54,647 INFO  [z->issue create z   ] [tzJobProcessor7] [issue create z] [admin]
GU isreported - false
GU becomesreported - true
21 jul 2017 13:05:54,663 INFO  [z->issue create z   ] [tzJobProcessor7] [issue create z] [admin]
HTTP/1.1 404 Not Found
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><error>Issue not found.</error>

2. isReported()

when isReported() {
  info("\r\nGU isreported - " + issue.isReported() + "\r\nGU becomesreported - " + issue.becomesReported());
  addHttpHeader("Content-Type", "text/html");
  addHttpHeader("Authorization", "Basic *******");
  info("\r\n" + doHttpGet(("http://youtrack:9999/rest/issue/" + getId())));
}

Logs are:
a). from agent (Web-interface)

21 jul 2017 13:08:03,911 INFO  [z->t1               ] [tp55562178-1104] [t1] [admin@192.168.0.1]
GU isreported - true
GU becomesreported - true
21 jul 2017 13:08:03,921 INFO  [z->t1               ] [tp55562178-1104] [t1] [admin@192.168.0.1]
HTTP/1.1 404 Not Found
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><error>Issue not found.</error>

b). from email

No Logs.

With best regards.

0

Losandreas, I'm sorry for the delay. If you just need to send a notification, please use the becomesReported() method.

Let us know the results. Thanks!

0

No. As I told earlier - one time (when issue created or comment added) do something with api in new issue or comment. More accurately - I need to remove some attachments when issue created or comment added. With native workflow editor I can't do that, but with api can. BUT when issue.becomesReported() or comments.added.isNotEmpty - api can't see new issue or new comment. I thought isReported() can helps me - if it always "reported" then api can use new element. But behavior which I wrote - told's me that I was wrong. Now "bad" decision is every hour I check all issues and all comments for "not needed" attachments and remove them.

0

Hi Losandreas!

 

> BUT when issue.becomesReported() or comments.added.isNotEmpty - api can't see new issue or new comment.

This happens because these entities (Issues and comments) are created only after the workflow is triggered.

So I believe that a scheduled rule is a pretty good solution in your case.

0

Please sign in to leave a comment.