- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-31-2020 06:49 AM
In my client script I am trying to get the value of a dropdown field on my form. This code below works to display the names of the fields.
for (var x in $scope.data.f._fields) {
alert(x);
}
Here is the html:
<sp-model form-model="data.f" mandatory="mandatory"></sp-model>
And then the server side code produces the form with this line:
data.f = $sp.getForm(data.table, id, '', 'SPView');
I've tried so far with code like:
g_form.getValue([field name here]);
but I'm getting a javascript error that g_form is undefined. I'm wondering if it is due to the construction of the html, and maybe if the form section needs to be wrapped in something or do I need to include a library of some sort?
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-31-2020 07:08 AM
Assuming that your code is in a widget of Service portal, g_form does not work there. to get a value in a client controller you can use something liek this
$scope.$on("field.change", function(evt, parms) {
if (parms.field.name == 'your_field')
c.data.yourfield = parms.newValue;
});
Mark the comment as a correct answer and helpful if this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-31-2020 06:56 AM
The g_form api is not available in Service Portal.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-31-2020 07:08 AM
Assuming that your code is in a widget of Service portal, g_form does not work there. to get a value in a client controller you can use something liek this
$scope.$on("field.change", function(evt, parms) {
if (parms.field.name == 'your_field')
c.data.yourfield = parms.newValue;
});
Mark the comment as a correct answer and helpful if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2022 01:08 AM
Hello Asifnoor,
how this can be retrieved in html code?
like,
{{c.data.yourfield}} ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-01-2025 09:27 AM
Hi @asifnoor ,
This code is working when we changed the value of the field and save the record but not when we save record without changing the value