How to access values in Widget Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2020 06:15 PM
Hi,
I cloned form widget and how can I access the value of following duration field in Client Scripts for validation?
<input type="text" class="form-control ng-valid ng-dirty ng-valid-parse ng-not-empty ng-touched"
id="dur-hours-u_start_date_of_activity" ng-model="parts[unit]" ng-disabled="field.isReadonly()"
ng-change="updateDuration()" title="Hours" role="textbox" aria-invalid="false" style="">
<input type="text" class="form-control ng-pristine ng-untouched ng-valid ng-not-empty"
id="dur-minutes-u_start_date_of_activity" ng-model="parts[unit]" ng-disabled="field.isReadonly()"
ng-change="updateDuration()" title="Minutes" role="textbox" aria-invalid="false">
Thanks,
Ashraf
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2020 06:49 AM
You can use the $scope variable to get or set any values.
Please look at this link for more info- https://serviceportal.io/g_form-api-in-embedded-widgets/
Please hit correct based on impact of solution.
Thanks
Nitin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2020 07:07 AM
Thanks Nitin. Since, it is duration field with the same name and it is split in hours, minutes and seconds.
I just need to find way to extract values based on the ID. Any suggestions?
<input type="text" class="form-control ng-valid ng-dirty ng-valid-parse ng-not-empty ng-touched"
id="dur-hours-u_start_date_of_activity" ng-model="parts[unit]" ng-disabled="field.isReadonly()"
ng-change="updateDuration()" title="Hours" role="textbox" aria-invalid="false" style="">
<input type="text" class="form-control ng-pristine ng-untouched ng-valid ng-not-empty"
id="dur-minutes-u_start_date_of_activity" ng-model="parts[unit]" ng-disabled="field.isReadonly()"
ng-change="updateDuration()" title="Minutes" role="textbox" aria-invalid="false">
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2020 07:13 AM
Hi,
ng-model is used for the two way binding means it bind the value on HTML and server side. So if you want to access the declared variable in HTML used ng-model and in client script you can access it by c.variable or $scope.variable name, where c is work as a controller in angularjs.
Mark it correct or helpful.
Thanks
Bhagyashri Sorte.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2020 07:23 AM
Thanks for your response. I'm trying to validations on the duration field and need a way to get data based on ID. Since, variable name is same for hours,minutes and second
Any ideas?
