Is it possible to hide a page/section from a user in Jira Service Desk with ScriptRunner

Silas Alexander Lykke Rosenskjold January 11, 2021

Hi everyone,

 

I have two quick about hiding elements/pages from a user in Jira Service Desk.

 

Is it possible to hide a certain page inside a project from a specific user with ScriptRunner?

I would like to hide the page /customers in a service desk for a specific service desk agent.

 

I know there's a built-in script that can hide the menu icon for customers.

Is it possible to do on a user-level, so that only a particular user in a project doesn't see that menu icon?

 

Thanks a lot in advance :)

Jira server: 8.13.1

Jira service desk: 4.13.1

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Joanna Choules
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.
January 11, 2021

Hi Silas,

In the condition code of the built-in script, you can check which user is logged in with the JiraAuthenticationContext:

def user = ComponentAccessor.jiraAuthenticationContext?.loggedInUser

and use that to decide whether to show or hide the icon.

Joanna Choules
Adaptavist Product Support

Silas Alexander Lykke Rosenskjold January 11, 2021

Thank you!

Do you know if it would be possible to hide the content on a certain URL altogether using the same check?

Joanna Choules
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.
January 11, 2021

The script isn't built for hiding entire pages, but if you can identify the UI elements containing the content you don't want to be shown (the fragment locator might help with this), then you can hide those as well.

Silas Alexander Lykke Rosenskjold January 12, 2021

Yes indeed. 

I realized yesterday in the evening, that I simply need to hide whatever I need in the same way.

I'm having some trouble locating the id for the section I need to hide. The "Hide UI Element" script only takes Ids that start with com.atlassian something, but the section I would like to hide doesn't have a com.atlassian Id, just an id like this: div.js-page-panel-content.sd-page-panel-content

Joanna Choules
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.
January 20, 2021

How did you find this ID? It looks like it might be a CSS selector, but Jira uses its own naming system for UI components.

Silas Alexander Lykke Rosenskjold January 21, 2021

Hi Joanna. 

It's the ID I'm getting for the web section showing the customers list in a service desk project. I find it by highlighting it in developer mode:

web section question.png

The problem I'm facing is that I'm trying to hide the customer list here, but it doesn't have a unique ID from what I can tell, because it's not a web element, but a web section.

 

From what I understand, I'll have to create a .js script to hide this, but I'm not sure how to set this up for a specific user. 

Joanna Choules
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.
February 3, 2021

Hi Silas,

Thanks for clarifying. In Javascript, you can determine which user is logged in as follows:

JIRA.Users.LoggedInUser.userName()

and use that to decide whether to hide the element.

TAGS
AUG Leaders

Atlassian Community Events