Testing g_form in Chrome console
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-05-2020 03:02 PM
Is it possible to invoked methods on g_form in the console of chrome? I tried and it did not find the object. Wondering if there is any wrapper or in anyway. Appreciate it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-06-2020 03:06 PM
Instead of doing concole.log try doing alert(g_form code). It will show in a popup. Also I noticed you had get_reference when it should be g_form.getReference('filed name', function callback);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-07-2020 06:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-22-2022 07:31 AM
I figured this out. You must right-click and inspect the page first in Chrome. Then you have access to g_form via the console.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-18-2023 01:48 AM - edited ā07-18-2023 03:54 AM
Are you sure that's all you did? I am trying to speed up my Catalog Item client side testing by setting up some Variable values on a long form and still get this "g_form is not defined" error.
EDIT: seems like this only works for forms, not catalog items, as I tested the below and for anything that is not directly mapped to a target record field, a "g_form is not a function" error is returned.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0695239
Ended up using Tim Woodruff's solution instead: https://www.servicenow.com/community/developer-articles/set-catalog-variables-from-url-params-free-t...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-17-2023 01:57 AM
Hello Community,
to used the g_form command in the browser console, it is (sometimes) necessary to switch to the gsft_main frame.
Therefore, take a look at this Knowledge Article from ServiceNow:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0695239
It is then possible to create e.g. an alert - alert(g_form.getValue('<variableName>')); - or
to create a console log entry - console.log(g_form.getValue('<variableName>'));
Do not forget the quotation marks ' ' š.