- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 01:53 AM
hi
i have used checkbox in portal widget. by default value is checked.
I am trying to get checkbox value , it is displayed as undefined. Ideally value should be retrieved as true. Please suggest.
screenshot:
<label><input type="checkbox" name=user_access" ng-model="data.user_access" ng-checked="true"> User Access</label><br/>
//value in client script
spUtil.addInfoMessage("hi01" + $scope.data.user_access);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 02:58 AM
Hello @Ujjwal1 ,
Are you populating the value in the Server Script? If not please add something like this there:
data.user_access = true;
Then you can change the HTML to this (please note there was also a missing double-quote in the "name" attribute, which is fixed below):
<label><input type="checkbox" name="user_access" ng-model="data.user_access">User Access</label>
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 02:01 AM
it means it's unable to get the value.
share the complete widget
Did you initialize the checkbox?
$scope.data = {
user_access: true
};
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 03:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 02:07 AM
Hello @Ujjwal1
I can see you have initialized it already. Can you just add "ToString" at the end while getting the data.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 02:58 AM
Hello @Ujjwal1 ,
Are you populating the value in the Server Script? If not please add something like this there:
data.user_access = true;
Then you can change the HTML to this (please note there was also a missing double-quote in the "name" attribute, which is fixed below):
<label><input type="checkbox" name="user_access" ng-model="data.user_access">User Access</label>
Regards,
Robert