how to load and call the javascript file into servicenow business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2017 01:58 AM
Hi ,
From My Application I have written 3 JavaScripts files which used to call a Rest API.
I wanted to call the same Rest API from ServiceNow Through Some Business Rules so that I dont have to write the Code again.
What is the way to use the same javascripts file in my Business Rules.
Thanks and Regards,
Subrata
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2017 09:34 AM
Hey Subrata,
It sounds like you are trying to perform an integration between ServiceNow and some other software via REST. You should be able to call the other API and put in values from the record using the "Current" Object
As to reusing the same code over and over again, you should look into writing a script include and housing the javascript files there, and calling it from those business rules.
Do you have any more specifics about what you are trying to do?
Best,
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2017 09:39 AM
Hi Andrew,
Thanks for your Input.
Actually it was my fault that my description is not to the point .
I have used the Business Rule and Scripts Include already.
But I just wanted to know how to upload the JS file within serviceNow instance . As I didn't find the Upload option for a JS file under "System Defination"
and after uploading the JS file how to instantiate those file , that is my queries .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2017 10:02 AM
Hey Subrata,
This is not something that is done very often, there is no "upload js library" function in ServiceNow. What are the JS files you are trying to import. When I have seen it done, I have seen the code (usually the .min file) copy pasted into UI pages or script includes.
If you take your javascript functions and paste them into a script include, you can then call and use those files the same way your would a script include, any reason this would not work for you?
Best,
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 10:23 AM
Hi Andrew,
Actually In our Environment we are importing the below mentioned file.
my imports:
<script>https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/hmac-sha1.js"></script>
<script>https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/components/sha256-min.js"></script>
<script>https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/components/enc-base64-min.js"></script>
then through Crypto-JS file we are able to do the encryption ..
I used do the same thing which you have mentioned through Scripts Include, and for this also I have uploaded the Same Crypto-JS file and create Class through which i am doing the same thing which I have done in my Local environment.
but Problem is generated signature in ServiceNow is not working where else generated Signature in my Local application is working .
I am calling the 3rd Party API with this Signature, 3rd Party API accepting signature of Local machine not the ServiceNow one.
any other option do you have for CRYPTO, or else like in NODE.JS ( Crypto | Node.js v8.4.0 Documentation ) we have a crypto module, can we upload/work with that module in ServiceNow .