Get Value from field in service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2017 09:44 AM
Hello everyone,
In the service portal, I am trying to get the value of one field in my widget, to use this value for redirection
So I have tried in my controller $scope.page.g_form.getValue('u_otp'); , I have field name u_otp in my form but this doesn't seems to works
Does anyone has an idea, how could i do it ?
- Labels:
-
Service Catalog
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2017 10:01 AM
Outside of the Service Catalog, there is currently no clean way to do this (unless I'm not aware of new functionality in Jakarta). I'm assuming you're using the Form Widget, or an extension thereof. You can kludge it up by trying to pull the value directly from the DOM, which no one in their right mind would recommend. The slightly better option is to use an event-driven method, such executing an event and passing data from an onChange Client Script. You can then listen for that event in your Widget Client Script.
For example:
Client Script:
// answer should ideally be your data as JSON
CustomEvent.fire('your_event_name', yourJSONData);
Widget Client Script:
CustomEvent.observe('your_event_name', function(yourData) {
if (yourData) {
// Do your logic.
}
});
Hopefully this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2017 10:11 AM
Not really, because sometimes the value is already inside the form, and the user doesn't change it, so I can't record it 😕
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2017 10:59 AM
Run the script onLoad then.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2017 11:11 AM
I would refer to get the value from the server and then use it in controller.