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
‎02-02-2017 08:31 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2017 09:03 PM
$scope is not defined in UI Scripts
ReferenceError: $scope is not defined
I've also noticed that the Script Editor tells me 'g_form' used out of scope
I want to use this in scope.
I'm looking for it to be cross-compatible, i.e.
if (g_form === undefined)
var g_form = /*Code here*/
g_form.addInfoMessage('addInfoMessage: ' + msg);
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
‎02-02-2017 09:06 PM
Oh Sorry..my Bad. I got it wrong.
I thought you were trying the code in the client controller.
Let me take a look into it and come back
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2017 07:41 AM
Did you get this working ?