Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Opening Issue in Browser

So the problem here is that i want tp capture the useragent String value when i open the issue in the browser , let alone make any changes .For it i have created the scripted field which captures the value 

According to my understanding the value of the user agent is only captured from the HTTP request which is sent to the server when any changes are made to it . But is it possible to get the user agent value only by opening the issue on the browser or when just refreshing the browser , If possible can you please how to do it 

2 answers

1 accepted

0 votes
Answer accepted

Hi @acc1211 

You can try with HttpContext.getRequest() to capture the browser user agent. For example, using the following script on the scripted field to display the user agent when user view the issue on different web browsers:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.sal.api.web.context.HttpContext

def httpContext = ComponentAccessor.getComponent(HttpContext)
def request = httpContext.getRequest()

if (request) {

return request.getHeader("user-agent")

}

Google Chrome:

Screenshot 2021-03-22 at 4.20.11 PM.png

Firefox:

Screenshot 2021-03-22 at 4.20.45 PM.png
I hope this helps.

Hi @acc1211 

You can capture request with com.atlassian.sal.api.web.context.HttpContext package. For example, test this script via Script Console:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.sal.api.web.context.HttpContext

def httpContext = ComponentAccessor.getComponent(HttpContext)
def request = httpContext.getRequest()

if (request) {

log.warn request.getHeader("user-agent")

}

You will get the user agent information from the Logs tab. Its the same apply in the scripted field. I hope this helps.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

🎨 Add some visual life to your templates

Hi Atlassian Community, My name is Avni Barman, and I am a Product Manager on the Confluence Cloud team. Based on feedback from you, we are giving admins more power to create templates that a...

123 views 1 4
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