This menu option lets you make a smart redirection to Jira pages. You can find Vendor's information here. To tell you the truth, I spent a couple of hours to understand why we need this feature and how to use it. I feel that it is better to explain this feature with an example. Here is the example.
Suppose, each employee files invoices each month in Jira.
As you can see Alexey Matveev filed two invoices for March and April.
But HR works in an external system where the payment is done and in this external system HR officer must be able to see the latest invoice, which was filed in Jira, for each employee.
Of course this HR officer can login to Jira, open Issue Navigator and filter all issues in the Invoices project by employee ordered by the Invoice Date custom field in the descending order and the first invoice will be the latest invoice.
project = INV and reporter = amatveev order by "Invoice Date" desc
But it is a too complicated approach. We would like to be able to access the latest invoice by a link in our HR system.
But what will be the link?
We can not make this link look like this: http://localhost:2990/jira/browse/INV-2. Because this invoice will be the latest in May but not the latest in June. Do we need to change this link every month in our HR system? It sounds too complicated! We need a simpler solution.
And the Redirect Page Configuration will help you here.
Let's configure it.
In our HR system we can make the link look like this:
http://localhost:2990/jira/plugins/servlet/kredi?userName=Alexey+Matveev
As you can see we call the plugins/servlet/kredi servlet which will do smart redirection for us and also we pass Alexey+Matveev as the user name parameter which will tell the servlet for which user we need the latest invoice.
Now we need to make our servlet smart. Open the Redirect Page Configuration menu and enter the following code:
string userName = argv["userName"];
if (isNull(userName)) {
return "/plugins/servlet/kredierror?customErrorTitle=User Not Provided&customErrorMessage=Provide user with userName parameter";
}
if (isNull(getUserByFullName(userName))) {
return "/plugins/servlet/kredierror?customErrorTitle=User Not Found&customErrorMessage=User " + userName + " not found";
}
string [] k = selectIssues("project = INV and reporter = " + getUserByFullName(userName).username + " order by \"Invoice Date\" desc");
if (size(k) == 0) {
return "/plugins/servlet/kredierror?customErrorTitle=Invoice Not Found&customErrorMessage=No invoices for "+ userName;
}
return "/browse/" + k[0];
The script does the following:
Well, let's test it!
First let's make a link like this:
http://localhost:2990/jira/plugins/servlet/kredi?userName=Alexey+Matveev
If we click on this link we will see the following screen:
Correct! We were redirected to my latest invoice.
Now let's not pass the userName parameter:
http://localhost:2990/jira/plugins/servlet/kredi
And we were redirected to the error page:
Correct!
Now, let's provide the user name who does not exist in Jira
http://localhost:2990/jira/plugins/servlet/kredi?userName=Super+Man
We were redirected to the error page:
And now let's provide a user without filed invoices:
http://localhost:2990/jira/plugins/servlet/kredi?userName=Tomas+Brook
Again we were redirected to the error page:
So, our program works correctly!
In short, we moved all logic for redirecting us to the correct page to Jira. And it is very handy because we can implement our logic with the SIL language which makes manipulation with Jira easy.
Alexey Matveev
software developer
MagicButtonLabs
Philippines
1,574 accepted answers
0 comments