- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2022 11:15 PM
$index cannot be used here, reason being we need to know the id of the record here, so that when a user clicks on Remove button ServiceNow will know which record to query and then delete from the table you want.
Only thing pending here is to know the sys id of the record on which action is happening.
Only Change which you need to try is in Remove button by passing the correct record sys id.
Just Change the remove button line number 16 in your HTML as below:
<td><button id ={{data.teamsysID}} ng-click="confirmDelete(data.teamsysID)">Remove</button></td>
No other change is needed in your widget and try now to see what is coming in alert messgae.
Also have modified to put one more alert in line number 13 , so please update your client controller as below and let me know what alert you are getting now after you click on Remove Button:
function($uibModal,$scope,$rootScope,spModal,spUtil){
var c =this;
var userData = [];
var team = '';
$rootScope.$on('selectTeam', function(event,data){
c.server.get({
action:'getTeam',
teamID:$rootScope.teamID
}).then(function(r) {
c.data.member = r.data.teamMembers;
c.data.teamName = r.data.teamName;
team = r.data.teamName;
alert('Value of CLient ID ' + r.data.teamsysID);
});
});
c.openModal = function(){
c.modalInstance = $uibModal.open({
templateUrl: 'modalTemplate',
scope: $scope
});
}
c.closeModal= function() {
debugger;
var user = $('#user').select2('val');
var teamName = $('#team').select2('val');
c.server.get({
action: 'createRecord',
selectTeam: teamName,
userName: user
}).then(function(r){
$rootScope.$emit('createRecord',r.data);
});
c.modalInstance.close();
}
//Delete record
c.confirmDelete = function(idx){
c.server.get({
action:'confirmDelete',
ID:idx
}).then(function(response) {
//Process your response
c.data.retrivedList = response.data.incList;
alert("Received data from server" + c.data.schedList.toString());
});
}
}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke