- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2022 06:51 AM
How to test a piece of javascript quickly?
Do you have to test it in client ui policy or business rule? fix script? which is quick and convenient? for example, to query GlideRecord?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2022 08:47 AM - edited 12-03-2022 08:47 AM
Javascript Executor is only for client-side code, and you shouldn't use GlideRecord in client-side code.
If you are just trying to test the js executor, try this simple line
alert("Hello from the Javascript Executor");
To learn more about scripting, I highly recommend this
and
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2022 08:37 AM
that works, thanks!
can I save background script to rerun it again? right now, after running one time, it only gives a history link
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2022 08:39 AM
No problem!
If you want to save a server side script to run it on demand, you can create a fix script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2022 08:45 AM
If you want to save the script and rerun it, fix script is the best.
For client side execute script in javascript executor.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2022 08:41 AM
from the javascript execute, I tried to run the following code. but looks like nothing happens after clicking run. anything wrong with my code?
var gr = new GlideRecord('incident');
gr.addQuery('active', true);
gr.query();
while(gr.next()) {
alert('Incident count: ' + gr.getRowCount());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2022 08:46 AM - edited 12-03-2022 08:47 AM
This is because you are trying to run server side code in javascript executor, you need to run client code here.
Raghav
MVP 2023