Calling Server Side Script includes from UIB Client Scripts

servicenow client-scripts rest-api next-experience

Enable AI Animation

This could be improved a lot.

Let’s first talk about how this is working for me.

Everything I read to do this either says make a rest call or use the “new transform data resource”. When trying the data resource it never seemed to run the script include. So I went with rest. I’m sure I missed something I’ll be asking Tomas about this.

My working steps.

  1. Find or Create a Script Include
  2. Create a REST Endpoint that calls your Script Include
  3. Create a Client script using the helpers and snHttp method to call said REST endpoint
  4. Profit

helper has a method called snHttp, which by default batches your request up (you can set an option of batch to false to stop that.)

To take advantage of a rest call to call a server side script include, you’ll need to make a rest api … really?

yep. one thing to note is you can use the async/await in the uib client scripts so that’s nice.

ServiceNow Docs on Helper

Community post on Client Side Script Includes (says to do this you need to make a rest call)

Useful examples of snHttp


View this page on GitHub.