- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2022 11:35 AM
Hi all,
I have a custom Service Portal widget form that we are using for tracking a user's selections based on a set of questions.
I'm attempting to pass a value from the Service Portal widget's Html form field, to an embedded widget which calls a Record Producer. My objective is to use the widgets input selections to set record producers variable selection. I've attempted to use the below Client Controller that doesn't work. Any help would be great. Thank you.
$scope.page.g_form.setValue('hidden_widget_value', 'test');
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 11:12 AM
The $scope.page.g_form only works if g_form is brought into widget. If you didn't make any modifications to the SC Catalog Item widget then the way to use $scope.page.g_form is embedding the widget through a variable within the RP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2022 01:22 PM
Is the embedded widget custom as well?
Doing this sort of thing depends on how the embedded widget is scripted. When passing values to an embedded widget it (two ways to do this: client side is using spUtil and server side is $sp.getWidget), accepts the values on the "input" (via spUtil.get) object of the embedded server side or as "options" (via $sp.getWidget) in the embedded widget.
So the embedded widget server script should be looking for what you're passing either through the input object or options object. Then accessing that from the client side of the embedded widget either via the HTML template directly from the data object, or in client controller via $scope.data or c.data.
Or another way of doing this pushing the data values as parameters on the url and have your embedded widget use $sp.getParameter to access the parameters.
Or use a catalog client script to grab the parameters off the url, parse them, and assign them to the form variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2022 01:37 PM
Oops, I think you mean you are embedding the widget as a variable on a Record Producer.
In that case are you wouldn't be setting values to a widget but rather setting values from within the embedded widget. Meaning from the client controller of your embedded widget $scope.page.g_form accesses the variables on your Record Producer.
$scope.page.g_form.setValue('rp_field_name', 'value')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2022 06:54 PM
Yes, the record producer is embedded into the widget Body HTML. See below for an example.
<widget id="widget-sc-cat-item-incident"></widget>
So, I would like to set a variable located in the referenced above widget/record producer. Thank you for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 05:35 AM
That looks to be a custom widget. Does that widget have scripting in there the looks for data coming in from input, options or url parameters and feeds them to the client side?
Also, I forgot about this method of embedding widgets. When embedding widgets in this manner it takes options like so:
<widget id="widget-sc-cat-item-v2" options="an object goes here"></widget>
The object would contain properties correlating to the options schema of the embedded widget.
Since it looks like your custom widget is mimicking the RP widget may I ask why not just embed the OOTB RP widget and lock it down to a specific RP, in this case it seems to be for incident?