- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2018 05:58 PM
I want Comments field to be mandatory every time user Approves or Rejects a request. I tried using below link and was able to create comments box but it's not working properly, i can still Approve/Reject the ticket without entering any comments.. Kingston
https://community.servicenow.com/community?id=community_blog&sys_id=228da669dbd0dbc01dcaf3231f9619f3
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 07:08 AM
Oh...Why do you have two action functions in client controller? You should remove one
c.action = function(state) {
if (c.data.comment == '' )//&& state == 'rejected'){
{
$window.alert('Comments cannot be empty')
return false; }
c.data.op = state;
c.data.state = state;
c.server.update(); } //H
var ESIGNATURE = {
"approved": "cbfe291147220100ba13a5554ee4904d",
"rejected": "580f711147220100ba13a5554ee4904b"
};
spUtil.recordWatch($scope, "sysapproval_approver", "state=requested^sys_id="+ c.data.sys_id);
c.action = function(state) {
if(c.data.esignature.e_sig_required) {
var requestParams = {
username: c.data.esignature.username,
userSysId: c.data.esignature.userSysId
};
spUIActionsExecuter.executeFormAction(ESIGNATURE[state], "sysapproval_approver" , c.data.sys_id, [] , "", requestParams).then(function(response) {
});
} else {
c.data.op = state;
c.data.state = state;
c.server.update();
}
}
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 07:08 AM
Oh...Why do you have two action functions in client controller? You should remove one
c.action = function(state) {
if (c.data.comment == '' )//&& state == 'rejected'){
{
$window.alert('Comments cannot be empty')
return false; }
c.data.op = state;
c.data.state = state;
c.server.update(); } //H
var ESIGNATURE = {
"approved": "cbfe291147220100ba13a5554ee4904d",
"rejected": "580f711147220100ba13a5554ee4904b"
};
spUtil.recordWatch($scope, "sysapproval_approver", "state=requested^sys_id="+ c.data.sys_id);
c.action = function(state) {
if(c.data.esignature.e_sig_required) {
var requestParams = {
username: c.data.esignature.username,
userSysId: c.data.esignature.userSysId
};
spUIActionsExecuter.executeFormAction(ESIGNATURE[state], "sysapproval_approver" , c.data.sys_id, [] , "", requestParams).then(function(response) {
});
} else {
c.data.op = state;
c.data.state = state;
c.server.update();
}
}
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 07:51 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 08:33 AM
No. You can only pass one parameter to window.alert, and thats the message. You can't pass title.
But there could be other methods to show the popup where you can pass title as well.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2018 01:30 AM
Can you share your final script if this worked for you? Thanks a lot in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2019 04:54 PM
sorry for late reply. Here is the final Client script code
function ($scope, spUIActionsExecuter, spUtil, $window, spModal) {
var c = this;
var ESIGNATURE = {
"approved": "cbfe291147220100ba13a5554ee4904d",
"rejected": "580f711147220100ba13a5554ee4904b"
};
spUtil.recordWatch($scope, "sysapproval_approver", "state=requested^sys_id="+ c.data.sys_id);
c.action = function(state) {
if (c.data.comment =='' || c.data.comment==undefined)//&& state == 'rejected'){
{
$window.alert('Please enter your Comments, Thanks!')
return false; }
c.data.op = state;
c.data.state = state;
c.server.update();
//reloading window after ui action location.reload(); //here
}