Widget Server Script Adjust CSS

ewok
Giga Contributor

I am looking to hide and unhide a bit of text on a service portal widget. I have already placed the text in a span with an ID in the HTML and i have the CSS related visibility set. However I can't seem to find a way to effect this CSS with the server Script. I have already the logic setup to turn on and off this text but can't figure out how adjust this CSS. 

----HTML-----------

<h4 class="panel-title">${Case Record {{::record.number}}} <span id="parent"><br/>(Parent Case)</span></h4>

------CSS-------------

#parent {
visibility: hidden;
}

7 REPLIES 7

Patrick Fedigan
Giga Guru

Hello ewok,

I'm not quite sure of a way to directly change some CSS via a server script. Wouldn't have to be part of your client script? You may have to set up a client/server side call to get what you are looking for. 

Cheers,

I am fine with putting my logic in the client script too. Initially that was my thought. However i haven't been able to figure out how to say hide or unhide id="parent" with a server or client script. 

Hello ewok,

This link may help guide you: https://www.w3schools.com/howto/howto_js_toggle_hide_show.asp

Cheers,

Thanks still no luck for me. I found some community posts that say that the DOM document.getElementById("myDIV"); isn't supported. However others mention it working. More sites seem to say it is unsupported. 

https://serviceportal.io/docs/documentation/client_scripting.md

Unsupported client scripting globals

The following globals and APIs are unavailable in service portal client script:

  • window
  • document
  • $
  • jQuery
  • $$
  • $j
  • angular

 

I will keep trying and update if i find a solution.