The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Get object reference of ExtendedSystemInfoUtils

scriptIt
November 21, 2023

Hi Community,

How can I get object of ExtendedSystemInfoUtils in scriptrunner? ComponentAccessor is unable to get this component.

ComponentAccessor.getComponent(ExtendedSystemInfoUtils) is always null

Jirs api: https://docs.atlassian.com/software/jira/docs/api/7.1.4/com/atlassian/jira/util/system/ExtendedSystemInfoUtils.html

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
November 21, 2023

Hi @scriptIt

I ran a quick test in my environment and didn't encounter any issues.

If you observe the screenshot above, I can invoke the ExtendedSystemInfoUtils and access its methods:-

extendedSystem.png

To proceed, could you please clarify what version of Jira and ScriptRunner you are currently using?

I am looking forward to your feedback and clarification.

Thank you and Kind regards,

Ram

scriptIt
November 21, 2023

Hi @Ram Kumar Aravindakshan _Adaptavist_ ,

Thanks for your answer.

Jira version: 9.4.8

Scriptrunner version: 7.12

Output:
image.png

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
November 21, 2023

Hi @scriptIt

Ok, so if you want to declare the ExtendedSystemInfoUtils object, you can't directly use the ComponentAccessor.  

Instead, you need to use the ComponentAccessor to invoke the I18nHelper object. Once you have invoked it, you need to pass it to the ExtendedSystemInfoUtils constructor as shown below:-

import com.atlassian.jira.util.I18nHelper
import com.atlassian.jira.util.system.ExtendedSystemInfoUtilsImpl
import com.atlassian.jira.component.ComponentAccessor

def i18nHelper = ComponentAccessor.getComponent(I18nHelper)
def extended = new ExtendedSystemInfoUtilsImpl(i18nHelper)

extended.usageStats

Below is a screenshot of the output returned:-

image1.png

If you observe the screenshot above, I can get the result.

I hope this helps to solve your question. :-)

Thank you and Kind regards,

Ram

scriptIt
November 21, 2023

Hi @Ram Kumar Aravindakshan _Adaptavist_ ,

This is perfect.

Thanks for your help :)

DEPLOYMENT TYPE
SERVER
VERSION
9.4.8
TAGS
AUG Leaders

Atlassian Community Events