ServiceNow Application

119 Views Asked by At

How to do export and import the script includes functions to another javascript in servicenow application.

I need to call doMultipy fuction from another javascript file on servive now application. Anyone help on this? Code Snippet

2

There are 2 best solutions below

0
On

I am assuming when you say from another javascript file you mean to call this function from something like another script include, UI action, business rules, etc. You dont need to use import/export, you can do so by just creating object of this class:

new multiply().doMultiply(1,2)

If your script include is Accessible from: This application scope only, make sure your caller is also from same scope otherwise it wont allow you to access it.

0
On

If you want to call this script include from client side script then enable checkbox "client callable" to True. Then use makeAjaxCall from client side.

If you want this script include to be accessible from other modules then ensure you have selected "All Application Scopes" in the "Accessible from" field of the script include.