How to pass check box value in widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2021 03:43 AM
Hi Experts,
My requirement is I want to pass check box and Comments value to Server Side on clicking of button "Add" which is dynamic in widget -
I am trying below code, however I am getting undefined value and check box selection is getting blank .
I am beginner in widget designing . Can someone please help?
Thanks in advance,
I have written below code HTML Code -
<div class="panel panel-default">
<div class="panel-heading clearfix">
<h3 class="panel-title pull-left">
${Asset Certifications}
</h3>
</div>
<div>
<table class="table">
<thead>
<tr>
</tr>
<table>
<tr ng-repeat="alm in data.alms">
<td>
{{alm.number }}
<input type='checkbox' checklist-model="test" checklist-value='' ng-click="selectedList(alm.sys_id)" />
<label class="checkbox-inline"><input type="checkbox" value="">True</label>
<label class="checkbox-inline"><input type="checkbox" value="">False</label>
<label class="checkbox-inline"><input type="checkbox" value="">Comments</label>
</td>
<td></td>
<td></td>
</tr>
</table>
<div>
<input class="btn btn-primary btn-block" ng-click="c.addtoDashboard()" type="submit" value="Add">
</div>
Client Script -
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 Script -
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.alms = [];
var gr= new GlideRecord('alm_hardware');
gr.addQuery("assigned_to", gs.getUserID());
gr.query();
while(gr.next()){
var alm = {}
alm.number = gr.getDisplayValue('serial_number');
alm.short_description = gr.getDisplayValue('display_name');
alm.sys_id = gr.getUniqueValue('sys_id');
data.alms.push(alm);
}
//gs.addInfoMessage(input);
if(!input){
gs.addInfoMessage("return");
return;
}
else{
var selected_ids = input.selection;
gs.addInfoMessage(input.selected);
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2021 11:52 AM
You want to send sys_id from a reference field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2021 05:46 AM
I have done some changes and able to send the "sys_id".
Now I also want to send text value to reference record in Server side.
Can you please suggest ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2021 06:19 AM
You can get the details from sys_id on server side.
//Client side
c.requested_for={
displayValue: c.data.current_user.Name,
value: c.data.current_user.ID,
name: 'requested_for'
};
c.data.user_id=c.requested_for.displayValue
//Html
<sn-record-picker ng-required="true" field="c.requested_for" sn-model='c.requested_for'
table="'sys_user'"
default-query="c.data.query"
display-field="'name'"
value-field="'sys_id'"
search-fields="'name'"
page-size="10"
placeholder='Select User'>
</sn-record-picker>
// Server Side
if(input){
if(input.user_id){
//your code
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2021 01:43 PM
Please close the thread if it is resolved.