NOWCommunity Live Stream - Code Decoded - Using a Constants script include
HTML-код
- Опубликовано: 11 сен 2024
- In this video I'll show you how to make your server side JavaScript easier to maintain. We've talked about Script Includes as a way to improve unit testing, abstracting and reusing logic, but there's another use for them to help remove hard-coded values, decrease maintenance, and improve readability to the rest of your code.
Join us Mondays and Thursdays at 2PM UTC.
Episode topics include:
* Script Includes
Code snippets shown in this video are available at: github.com/chu...
References:
* Knowledge 2020 - knowledge.serv...
* Learn JavaScript on the Now Platform - bit.ly/sn-learn-js
* ServiceNow Developer Site - developer.serv...
* ServiceNow Developer meetups - meetup.com/pro...
* Book: No-Code Apps For Dummies - bit.ly/sn-ncafd
* TechNow Episode 6: Script Includes - community.serv...
* Docs: Script Includes - docs.serviceno...
Join the discussion on the community: community.serv...
Just for everyone who reads this comment: Often you would see the gs.include() mentioned in the code, Per Chuck its not needed and can be disregarded and need not use.
Awesome session as always:)
Thank you.
@@ChuckTomasi want to know how we can call script include through catalog client script in custom scope
Hello Chuck, Thanks again for very nice session ! I have few system properties defined and called in various SIs or scripted REST APIs...Accessing property values using Constants provides any performance benefits over repetitive gs.getProperty("P_NAME") ?
It's not any faster because properties are cached anyway. The main thing is if you need to change the property name (or default value - the second parameter), you only need to do it in one place.
Thanks for your job! Im searching for how I DO a Calculated COLUM in SERVICE NOW; i.e.
W = X + Y ...
Want tutorial on script include through catalog client script in custom scope
Hi Ayesha, you can call a script include from a client script (standard or catalog, scoped or global) using GlideAjax. Take a look at episode 33 of TechNow here: bit.ly/servicenow-technow
Have you seen the code in SN? Clearly most of the devs have lost their founders ethos!
Please email me some examples. I can share them with the product teams. I know that the concepts in this video are used in some places as it was originally pointed out to me by a colleague from some baseline scripts.
Chuck Tomasi have a browse through the scripted web services or any widget.
@@reddpill Given that there are a LOT of these records, can you point me at some specific examples?
@@ChuckTomasi @Chuck Tomasi Here's one I saw yesterday, and look into the associated script records for that end point. You might need to install the Event Module.
Scripted REST Resource > Inbound Event > Inbound Event Post
Also, not only widgets have a look through some of the business rules. The problem exists throughout the platform.