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

How can I add Javascript to Customer Portal?

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. 


6 answers

2 votes
Gerry Tan Atlassian Team Aug 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:

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.   

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.

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
Steven Behnke Community Leader Aug 31, 2016

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

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.


GGonna report you. Thanks alot

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

0 votes
Steven Behnke Community Leader Aug 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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Desk

Tell us how you've implemented Change Management

Hello Community 👋, I'm a product manager at Atlassian, looking at improving change management capabilities across our products. In particular, we're looking at bridging the gap between Dev & ...

270 views 0 5
Join discussion

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