- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2017 02:11 AM
Hi,
How to add the comments field in the OOB Approval widget and make it mandatory when the approvers rejects it.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2017 03:58 AM
Hi Selva,
Use the below and it wil work ( we have to change both client and server to update user comments in approval table)
Highlighted are the changes
Client controller:
function ($scope, spUtil, snRecordWatcher,spModal) {
if ($scope.options.portal == true || $scope.options.portal == 'true') {
$scope.contentColClass = "col-xs-12";
$scope.options.portal = true;
} else {
$scope.options.portal = false;
$scope.contentColClass = "col-sm-9";
}
$scope.data.op = "";
snRecordWatcher.initList("sysapproval_approver", "state=requested^approver=" + window.NOW.user_id);
function get() {
spUtil.update($scope);
}
$scope.$on('record.updated', function(name, data) {
get();
})
$scope.approve = function(id) {
$scope.data.op = "approved";
$scope.data.target = id;
get();
}
$scope.reject = function(id) {
c.onPrompt(id);
}
c.onPrompt = function(id) {
spModal.open({
title: 'Give me a comment',
message: 'Your comment please?',
input: true,
value: c.comment
}).then(function(comment) {
c.comment = comment;
if(comment)
{
$scope.data.comment = comment;
$scope.data.op = "rejected";
$scope.data.target = id;
get();
}
})
}
}
Server side:
Replace
if (input && input.op) {
var app = new GlideRecord("sysapproval_approver");
if (app.get(input.target)) {
app.state = input.op;
app.update();
}
With
if (input && input.op) {
if(input.op == 'approved')
{
var app = new GlideRecord("sysapproval_approver");
if (app.get(input.target)) {
app.state = input.op;
app.update();
}
}
else if(input.op == 'rejected' && input.comment)
{
var app = new GlideRecord("sysapproval_approver");
if (app.get(input.target)) {
app.comments = input.comment;
app.state = input.op;
app.update();
}
}
Thanks and regards
Swamy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2017 07:19 AM
Approvals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2017 07:29 AM
Hi,
My Client script looks something this so how to make this changes am not sure could please help
Client script:
function ($scope, spUtil, snRecordWatcher) {
if ($scope.options.portal == true || $scope.options.portal == 'true') {
$scope.contentColClass = "col-xs-12";
$scope.options.portal = true;
} else {
$scope.options.portal = false;
$scope.contentColClass = "col-sm-9";
}
$scope.data.op = "";
snRecordWatcher.initList("sysapproval_approver", "state=requested^approver=" + window.NOW.user_id);
function get() {
spUtil.update($scope);
}
$scope.$on('record.updated', function(name, data) {
get();
})
$scope.approve = function(id) {
$scope.data.op = "approved";
$scope.data.target = id;
get();
}
$scope.reject = function(id) {
$scope.data.op = "rejected";
$scope.data.target = id;
get();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2017 10:26 AM
Hi,
Can someone please help me with the above query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2017 03:58 AM
Hi Selva,
Use the below and it wil work ( we have to change both client and server to update user comments in approval table)
Highlighted are the changes
Client controller:
function ($scope, spUtil, snRecordWatcher,spModal) {
if ($scope.options.portal == true || $scope.options.portal == 'true') {
$scope.contentColClass = "col-xs-12";
$scope.options.portal = true;
} else {
$scope.options.portal = false;
$scope.contentColClass = "col-sm-9";
}
$scope.data.op = "";
snRecordWatcher.initList("sysapproval_approver", "state=requested^approver=" + window.NOW.user_id);
function get() {
spUtil.update($scope);
}
$scope.$on('record.updated', function(name, data) {
get();
})
$scope.approve = function(id) {
$scope.data.op = "approved";
$scope.data.target = id;
get();
}
$scope.reject = function(id) {
c.onPrompt(id);
}
c.onPrompt = function(id) {
spModal.open({
title: 'Give me a comment',
message: 'Your comment please?',
input: true,
value: c.comment
}).then(function(comment) {
c.comment = comment;
if(comment)
{
$scope.data.comment = comment;
$scope.data.op = "rejected";
$scope.data.target = id;
get();
}
})
}
}
Server side:
Replace
if (input && input.op) {
var app = new GlideRecord("sysapproval_approver");
if (app.get(input.target)) {
app.state = input.op;
app.update();
}
With
if (input && input.op) {
if(input.op == 'approved')
{
var app = new GlideRecord("sysapproval_approver");
if (app.get(input.target)) {
app.state = input.op;
app.update();
}
}
else if(input.op == 'rejected' && input.comment)
{
var app = new GlideRecord("sysapproval_approver");
if (app.get(input.target)) {
app.comments = input.comment;
app.state = input.op;
app.update();
}
}
Thanks and regards
Swamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2017 04:20 AM