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

How can I add Javascript to Customer Portal?

DoD Support August 30, 2016

We have an instance running JIRA  Server v7.1.8 with JIRA Service Desk 3.1.9.

 I need to include arbitrary javascript on the Customer Portal (globally or per service desk, I dont care which)

I can do this easily enough in JIRA core by using the announcement banner but it seems that the Customer portal banner will not allow it and simply renders the script tag as plain text. 

 

7 answers

3 votes
Gerry Tan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 31, 2016

There is no public API to allow you to do that. The closest you can do is to create a P2 plugin with web-resource module, and set the context to <context>customerportal</context>.

But again this is not a supported public API, and only available in server.

Read more about P2 web-resource plugin module here: https://developer.atlassian.com/jiradev/jira-platform/building-jira-add-ons/jira-plugins2-overview/jira-plugin-module-types/web-resource-plugin-module

DoD Support August 31, 2016

Fair enough. Do you know what source file in JIRA handles saving the content for the Service Desk announcement banners?

To be honest with you, I would rather modify the save method to not convert the html to html entities so that the tags placed in the banner are actually rendered as html on the portal, essentially duplicating the functionality of the JIRA Core announcement banner. 

We need our admin to have the ability to change the content when needed. The announcement banner is a perfect solution (aside from this self inflicted handicap).

It doesn't really make sense to us why Atlassian chose to block this feature on the customer side.   

1 vote
DoD Support August 31, 2016

Hi Steven, thanks for your time. I have to say that I disagree. The JIRA Core announcement banner renders whatever you put in it exactly as you enter it, nothing special there. When Atlassian designed the Service Desk announcement banner, they made the very intentional decision to to strip out the html tags by calling a method on the input such as StringEscapeUtils.escapeHtml() thereby blocking the administrator's ability to add html tags to the banner.  Atlassian states here their reasoning for that (basically that this was done on purpose because Project Admins can edit the SD Banner and Atlassian considers Project Admins to be less trusted than global admins.). 

While I get that, to a degree, all that would be needed to avoid this, is a checkbox on the Global admin side like "Allow HTML in SD Announcement Banner: Yes / No". This way, the Global Admin can decide if they trust their Project Admins (we do).

While a plugin type solution would work, I would prefer to find where Atlassian calls StringEscapeUtils.escapeHtml() (or similar) on the banner input before saving it to the database and simply remove that line. It really shouldn't be any more complicated than that. This would make the banners function the same way on Service Desk as they do on JIRA Core. 

Don't get me wrong, I didn't ask this just to complain. I was honestly hoping that we had just missed the setting to enable HTML somewhere.


Tiffany Owen
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 7, 2018

Hi. Did you ever find a solution to this? I would like to put just a few lines of css into the announcement banner on the customer portal. I agree that this feature is needed and should be easily changeable. Thanks

Like Marc Wampfler likes this
0 votes
Marco Brundel
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.
July 9, 2020
0 votes
Steven F Behnke
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, 2016

I think you have this backwards. Atlassian isn't 'blocking' the announcement banner from working. They haven't built in a way to render the HTML tags from the banner. It's likely all escaped and non-functional from the get-go, so a quick 'hack' to prevent or stop that doesn't exist.

This is something that is either considered from the get-go (like core JIRA) or that they build an API for – Neither of those occurred here. Again, they haven't 'blocked' you like you state – They never built that feature like you desire.

I can poke around to find the template used for the portal, but it wouldn't be easy or quick.

The best way would be to take Gerry's method. You could expose an admin screen so someone could add HTML as necessary as well. It is approached as a plugin though.

0 votes
Hayley Parker August 31, 2016

GGonna report you. Thanks alot

DoD Support August 31, 2016

I'm not sure what you mean by this. BTW, "alot" is not a word wink

0 votes
DoD Support August 31, 2016

That's sad. Any idea which template/file that would be? Or, better yet, what file can I edit to stop JIRA from rendering the content of the CP banner as plain text? If, I have to modify the source code, that would be a better solution IMHO.

 

0 votes
Steven F Behnke
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, 2016

You would need to modify the appropriate templates and files directly. There is no in-UI method to do so.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events