The CreatorCon Call for Content is officially open! Get started here.

Create UI Script with id and async properties

Miguel Flores
Tera Contributor

I'm working on integrating the OneReach chatbot in our service portal , and to do so I need to create a script with the async and id properties in it 

 

<script
id="rwc-embed-script"
async
src="https://chat.something-staging.onereach.ai/lib/richWebChat.umd.min.js"
></script>

 

but on creating a UI script these properties are not available , is there a way I can create it ?

1 ACCEPTED SOLUTION

RikV
Tera Expert

Out of the box servicenow does not support asynchronous scripting in ui script. So i dont know if it will work, especially not with embedded and external sources. But you can try:

 

  var script = document.createElement('script');
  script.id = "rwc-embed-script";
  script.async = true;
  script.src="https://chat.something-staging.onereach.ai/lib/richWebChat.umd.min.js";
  
  document.head.appendChild(script);
  
  script.onload = function() {
    console.log("Script loaded successfully.");
  };
  
  script.onerror = function() {
    console.error("Failed to load the external script.");
  };

 

 

View solution in original post

2 REPLIES 2

RikV
Tera Expert

Out of the box servicenow does not support asynchronous scripting in ui script. So i dont know if it will work, especially not with embedded and external sources. But you can try:

 

  var script = document.createElement('script');
  script.id = "rwc-embed-script";
  script.async = true;
  script.src="https://chat.something-staging.onereach.ai/lib/richWebChat.umd.min.js";
  
  document.head.appendChild(script);
  
  script.onload = function() {
    console.log("Script loaded successfully.");
  };
  
  script.onerror = function() {
    console.error("Failed to load the external script.");
  };

 

 

Miguel Flores
Tera Contributor

Yeah I tried something similar, but haven't made it work