- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 06:35 AM
I am working my way through a method for one service portal page to call another and pass arguments. At least, that's the idea.
As a waypoint along that path, I am trying to write a widget version of onChange(). Yes, $rootScope.$on('field.change', function(e,a) {...}) is the overall mechanism. Anyway, for various reasons, within that method, I want to access all the fields for this form (the widget in question is a copy of the OOTB form widget. So far, the only change is this onChange() handler, which is in the client controller). So, ideally, I would access the g_form object (which, thanks to code created for the old UI, but which did only most of what I wanted, I know exists). I've read, in several places, that $scope.page.g_form should provide that.
It doesn't. The $scope.page object does exist, but it has no g_form property (nor anything close, come to that. All of its properties, so far as I can tell, are strings).
Any thoughts on what stupid mistake I undoubtedly made here?
Thanks,
Dave
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 09:51 AM
Dave,
Get the reference at initialization, then use it on field change:
var g_form;
$scope.$on('spModel.gForm.initialized', function(e, gFormInstance) {
g_form = gFormInstance;
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 08:21 AM
can you try this once?
$rootScope.$on('field.change', function(evt,parms) {
var g_form = $scope.page.g_form;
spUtil.addInfoMessage("Form obj: " + JSON.stringify(g_form));
});
Coz it just worked for me in my instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 08:47 AM
I have already tried it, using both that 'frm' variable, and by directly trying
spUtil.addInfoMessage("Form obj: " + JSON.stringify($scope.page.g_form));
I get the same result with every variation I've tried.
Thanks again,
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 08:49 AM
where are you using this widget ?
is it in catalog item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 08:51 AM
No, it's a custom page that has only the (slightly) modified form widget and a slightly modified Icon Link widget (if I can figure this part out, the Icon Link will become important. So far, it isn't).
-Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 09:51 AM
okay so
what was the modification done ?