- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2019 12:41 AM
I am querying the sys_choice table to get the list of all the categories in the Server side script and passing those values in an array to the HTML side. I am creating check boxes for each categories. Below is my HTML side code:
<div>
<!-- your widget template -->
<div class="custom-control custom-checkbox" ng-repeat = "element in data.categories">
<input type="checkbox" class="custom-control-input" id="defaultUnchecked" >
<label class="custom-control-label" for="defaultUnchecked">{{element}}</label>
</div>
</div>
Here data.categories is an array having all of the incident categories.
I need to pass the selected checkbox values to server side script, so that it can fetch the related incident.
How can I do that?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2019 12:51 AM
you have to pass it to client controller and then you can update it to server side code.
i am giving you sample code here. . hope it will help you.
HTML:
<div>
<!-- your widget template -->
<table>
<tr ng-repeat="incident in data.incidents">
<td>
<input type='checkbox' checklist-model="test" checklist-value='' ng-click="selectedList(incident.sys_id)" />
</td>
<td></td>
<td></td>
</tr>
</table>
</div>
<div>
<input class="btn btn-primary btn-block" ng-click="c.addtoDashboard()" type="submit" value="Add">
</div>
Client Controller:
function($scope) {
/* widget controller */
var c = this;
var sect = []
c.addtoDashboard = function() {
c.data.selected = $scope.selection;
c.server.update().then(function(){
c.data.selected = "";
})
}
$scope.data.selection= [];
$scope.selectedList = function (y) {
//alert(y);
if (y) {
var index = $scope.data.selection.indexOf(y);
if (index === -1) {
$scope.data.selection.push(y);
}else{
$scope.data.selection.splice(index, 1);
}
}
};
}
Server side:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.incidents = [];
var gr= new GlideRecord('incident');
gr.addActiveQuery();
gr.setLimit(10);
gr.query();
while(gr.next()){
var incident = {}
incident.number = gr.getDisplayValue('number');
incident.short_description = gr.getDisplayValue('short_description');
incident.sys_id = gr.getUniqueValue('sys_id');
data.incidents.push(incident);
}
//gs.addInfoMessage(input);
if(!input){
gs.addInfoMessage("return");
return;
}
else{
var selected_ids = input.selection;
gs.addInfoMessage(input.selected);
}
})();
Note: Added sample code for your reference .
If it helped you, kindly mark it as correct and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2019 12:51 AM
you have to pass it to client controller and then you can update it to server side code.
i am giving you sample code here. . hope it will help you.
HTML:
<div>
<!-- your widget template -->
<table>
<tr ng-repeat="incident in data.incidents">
<td>
<input type='checkbox' checklist-model="test" checklist-value='' ng-click="selectedList(incident.sys_id)" />
</td>
<td></td>
<td></td>
</tr>
</table>
</div>
<div>
<input class="btn btn-primary btn-block" ng-click="c.addtoDashboard()" type="submit" value="Add">
</div>
Client Controller:
function($scope) {
/* widget controller */
var c = this;
var sect = []
c.addtoDashboard = function() {
c.data.selected = $scope.selection;
c.server.update().then(function(){
c.data.selected = "";
})
}
$scope.data.selection= [];
$scope.selectedList = function (y) {
//alert(y);
if (y) {
var index = $scope.data.selection.indexOf(y);
if (index === -1) {
$scope.data.selection.push(y);
}else{
$scope.data.selection.splice(index, 1);
}
}
};
}
Server side:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.incidents = [];
var gr= new GlideRecord('incident');
gr.addActiveQuery();
gr.setLimit(10);
gr.query();
while(gr.next()){
var incident = {}
incident.number = gr.getDisplayValue('number');
incident.short_description = gr.getDisplayValue('short_description');
incident.sys_id = gr.getUniqueValue('sys_id');
data.incidents.push(incident);
}
//gs.addInfoMessage(input);
if(!input){
gs.addInfoMessage("return");
return;
}
else{
var selected_ids = input.selection;
gs.addInfoMessage(input.selected);
}
})();
Note: Added sample code for your reference .
If it helped you, kindly mark it as correct and helpful.