Can we run the rest message script on the client side?

sanjay36
Tera Expert

Hey Everybody,

THIS Scenario is based INSIDE A scoped application..

I see we can utilize the Rest message script of service now inside a script include and call it from the client side.

In my scenario when i get the response from my Rest Get call i would have to do some validations and return a string to the client side and make some usual read only or visibility of the form fields.

I did found a way of utilizing the getXMLWait() in scoped applications by creating the Catalog Client script in Global Scope and add it to your catalog item.

So When i utilize the getXMLWait() Method it is taking a significant amount of time obviously processing all that script will freeze the user interface which is a bad user experience.

I was wondering if we can use the native java script in client scripts to do the rest call ? Does it work ? Thoughts ?

- Sanjay

2 REPLIES 2

Chuck Tomasi
Tera Patron

I haven't tried a native Javascript HTTP request to make a REST call. I'm not sure I recommend it however.



What is your use case for requiring synchronous client script/server script/REST? As you mentioned, it's a bad practice and bad user experience so we try to prevent people from going down that path in scoped apps.


Hi Chuck,

So we are doing an catalog item which requires running multiple REST API calls on change and onsubmit. SO the problem is the consistency of the response sometimes it returns the response sometimes it doesn't. I have been trying the other community links where we need to add some code to make the response wait . But i still see that inconsistency. I'm still trying to figure out solutions for this. Any help is appreciated on this.

 

Thanks,

Sanjay