Upload or include JS files in SN
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2015 02:11 AM
HI
I want to use some jquery elements in some requirement. I have added the code into UI scripts module and calling it by
<script language="javascript" src="CoolClock.jsdbx" />
But by inculding those files, I am not able to use CMS properly. While adding dynamic content to a page the browsers hangs up.
So do we have another method or utility by which we can include other js files so that it wont affect the core jquery libraries of SN.
Thanks
Deepak Ved Negi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2015 01:03 PM
I second this. I like to write alot of client code as reusable UI Script classes. It is troubling to have to use the document.write approach to inject these reusable scripts i'm creating.
It would be nice if all the client side script inputs supported a way to list requirements that corresponded to UI scripts , or some form of includes and the platform would ensure those scripts were injected into the document before executing the client script that leverages those dependencies.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2015 10:36 AM
Do you get the same errors if you include the script with jelly?:
<g:requires name="CoolClock.jsdbx" />
or
<g:include_script src="CoolClock.jsdbx" />
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2015 05:53 AM
Chris,
Can jelly be used outside of dynamic content blocks, such as in catalog client scripts or UI policy scripts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2015 06:52 AM
Kevin,
No. Jelly is used in UI pages or UI Macros such Dynamic Content blocks.
From the original post (I didn't see that it was an older post) it reads like he wanted to bring in UI scripts into a Dynamic Content Block. So I was proposing that he just use jelly instead of the normal script tags. Although it should have worked. The difference is that when you use the plain script tags in a Dynamic Content Block or UI page it renders like this:
<script> // .......content....... //</scirpt>
whereas if you use jelly to bring it in the slashes won't be included.
However, that said you can still build a library of reusable scripts and bring it into a UI page or Dynamic content block in the same manner.
If you wanted to build a reusable script library outside of dynamic content blocks then it is suggested to use script includes for that. For client side scripting make the script include a GlideAjax script.
Coding Best Practices - ServiceNow Wiki (reusable functions)
Client Script Best Practices - ServiceNow Wiki (GlideAjax script_include)
I don't think I really ever had to use document.write to bring in any scripts.