- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2019 06:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2021 05:00 AM
Create a widget as below
HTML:
<div class="panel b ng-scope">
<div ng-if="data.states != 4"> <!--4 is the value of cancel -->
<div class="panel-heading bg-primary panel-la-jolla-default">Actions</div>
<div class="panel-body" >
<button type="button" class="btn btn-danger btn-block" ng-click="c.uiAction('delete')">Delete</button>
</div>
</div>
</div>
CSS:
.header {
background-color: #2b0c99
}
Client Script:
function() {
var c = this;
c.uiAction = function(action) {
c.data.action = action;
if (c.data.action == 'delete') {
var ans = confirm("Are you sure, you want to delete it?");
if (ans == true)
update();
else
return false;
}
function update() {
c.server.update().then(function() {
c.data.action = undefined;
c.data.result = "completed";
});
window.setTimeout(restartscreen, 2000);
function restartscreen() {
location.reload(true);
}
}
};
}
Server Script:
(function() {
var gr = $sp.getRecord();
// Get table & sys_id
data.table = input.table || $sp.getParameter("table");
data.sys_id = input.sys_id || $sp.getParameter("sys_id");
data.canRead = gr.canRead();
if (!data.canRead)
return;
data.canWrite = gr.canWrite();
if (!data.canWrite)
return;
var states = "";
var b = $sp.getField(gr, 'state');
if (b != null)
states = b.value;
var stages = "";
var t = $sp.getField(gr, 'stage');
if(t != null)
stages = t.value;
var ReqCancel = "";
var c = $sp.getField(gr, 'u_asked_cancellation');
if(c != null)
ReqCancel = c.value;
// Valid GlideRecord
gr = new GlideRecord(data.table);
if (!gr.isValid())
return;
// Valid sys_id
if (!gr.get(data.sys_id))
return;
if (input && input.action) {
var action = input.action;
if (action == 'delete')
gr.deleteRecord();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2019 06:43 AM
Hi,
Set $scope.data.action to update or delete when the respective button is pressed, then on the server say if(input.action =="delete")
try with this,
Thanks,
Akshata
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2019 08:43 AM
Hi
HTML Code
<input type="button" sn-model='c.data.action' ng-click="postRequest()" class="btn btn-primary" value="Submit" ng-disabled="data.isPosting"/>
Client Side
$scope.postRequest= function() {
$scope.data.action='delete';
c.server.update();
}
Server Side
if(input){
gs.log('Server Side:'+input.action);
}
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2019 09:44 PM
It is not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2019 09:48 PM
Hi
Since Service Portal was primarily introduced for end users, and you're generally not giving end users delete access for records, it seems like that's not a very wide use case. If you're using the form widget in Service Portal, you could pretty easily just add a non-client side delete button to your form so that it shows in SP.