The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Client Script not working on Service Portal

Zod
Giga Guru

Hi Experts,

I understood, that normal client scripts will not work on service portal ... I also found some posts regarding this issue, but I don't get it. How to achieve ... you anyone please tell me in more detail what to do?

My on client scripts is something like this ...

function onLoad() {

  if (g_form.getUniqueValue() !== g_user.userID)

  {

  g_form.removeOption('u_abc', 1);

  g_form.removeOption('u_def', 1);

}

  }

21 REPLIES 21

Patrick Fedigan
Giga Guru

Hello,



Have you tried to set the UI type of the script to Both? Mobile and Desktop?



Cheers,


Ivano B
ServiceNow Employee
ServiceNow Employee

Hi Vem



According to this document



documentation/client_scripting.md at master · service-portal/documentation · GitHub



the script is absolutely ok.


Just in case i tried a similar code on my instance.


a.png



and it work fine. Please have a look to the next screenshots.



a.png



b.png



c.png



d.png



Just one thing. Did you select on the UI Type for the on Load 'Both' ?



Cheers


R0b0


In fact the UI Type was good to mention! 😉



Anyhow - it does not work. But I assume this might result due to other adjustments that where done on the widget. Have to check.


Will also check my dev instance ... if that is an home made issue ...


Thank you for the moment.


Will report back ... .


Just checked the Developer instance .... DOES not work either.



client script (on load, sys_user table, ui type both)



function onLoad() {


  if (!g_user.hasRole("xxxxxxx"));


  alert("Disable should be removed");


  g_form.removeOption('notification', 1);


  }



Added notification to portal view ....



Works fine - just NOT in Service Portal ... ;-(.


Also no Alert Message in SP