Referencing g_form in UI Script used in Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2017 07:12 PM
Hi Community,
We had a UI Script we were using to simplify Ajax calls throughout our system.
The UI Script does not work in Service Portal because 'g_form' is not defined.
We can work around this by passing in g_form as a parameter, but this seems unnecessary.
Is there a cleaner way to reference g_form from a UI Script used in Service Portal?
Thanks,
Paul
P.S. window.g_form does not work.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2017 06:14 PM
Not without passing in g_form as a parameter.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2018 06:19 AM
HI Paul,
How can I pass the g_form as a parameter into the ui script from my catalog client script?
Lets say I have ui script that control the hide and show of variables this kind of script:
g_form.setVisible("choose",false);
and I want the ui script to know the g_form.
Thanks,
Lior grinberg

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2019 05:38 AM
You have to pass it in.
Catalog Client Script
myUIScript(g_form);
UI Script
function myUIScript(g_form) {
g_form.addInfoMessage('hello');
}
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 05:02 PM
Hi Paul,
Not sure if this is Service Portal compatible, but you might be able to instantiate a new GlideForm object like so:
var gform = new GlideForm();
gform.addInfoMessage('This info message should appear at the top of the screen');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2017 02:22 PM
Did you ever find a solution?
We are trying to update our catalog items to work in service portal, and we were using g_form.setDisplay( to hide variables conditionally in an onload catalog client script