Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2019 06:20 AM
1 ACCEPTED SOLUTION
Options
- 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();
}
6 REPLIES 6
Options
- 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();
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2021 09:33 PM
In the server script after last line add this too
})();