Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

jira field url

Mehran Namdar August 24, 2019

Dear 

 

i want to search value in custom field in google

as i found script runner could help me to open link https://scriptrunner.adaptavist.com/latest/jira/fragments/WebItem.html

but how can append my custom filed value at the end of url ??

 

BR

Xarax

1 answer

0 votes
PD Sheehan
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 29, 2019

You can't using the "Navigate to link" option. The only variable available are $issue and $jiraHelper.

But if you select "do nothing" and then use a WebResource item and expose your own javascript to bind the new webItem (using the key from your webItem as the id of the DOM element), then you can use javascript to find and extract the custom field value and use that in your javascript event to pass the value to google.

Mehran Namdar August 31, 2019

Thanks peter

 

but i'm beginner and could not write javascript . 

could you please help me to write this code ?

 

BR

PD Sheehan
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 31, 2019

JS is not my area of expertise either.

You could try something like this:

AJS.toInit(function () {
var webItemKey = 'key-of-your-web-item';
var customFieldId = 10021;

var customFieldDivId = '#customfield_' + customFieldId + '-val';
var customFieldValue = AJS.$(customFieldDivId).text().trim();
var webItem = AJS.$('#' + webItemKey);
if(webItem){
webItem.attr('href', webItem.attr('href') + '&q=' + customFieldValue);
}
});

 With this example, you would continue to use "navigate to a link". All this does, it append the value of your custom field to the URL that you've specified in the webitem.

Just update the webItemKey and customFieldId to your values.

You'll need to save this to file in your [jira-home]/scripts directory and point to it using a "install web resource" fragment. There are some jira setup prerequisite that may require a jira restart (see the link above for details). Then in your install web resource, you need to identify a context for when this js file should be downloaded by the browser so that it's available and runs when the page refreshes.

Like Mehran Namdar likes this
Mehran Namdar May 7, 2020

Thank 

Ok now

PD Sheehan
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 7, 2020

If my answer helped you, I'm glad it did.

To help others find it, can you please click the "Accept Answer" button?

Thanks

Suggest an answer

Log in or Sign up to answer