Unable to access g_form in widget code

Dave Clemmer
Mega Guru

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

1 ACCEPTED SOLUTION

 

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;
            });

View solution in original post

10 REPLIES 10

 

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;
            });