
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 10:43 AM
I have a reject button where the Client box is checked, and the onclick field has the onRejectingBIR() function set.
The button shows up, and moves the record to the correct state. It even sends the comment to the work notes as expected. The only thing not working is rejecting the approval record.
Can anyone see what I'm doing wrong?
var currentRec = g_form.getUniqueValue();
var currentUser = g_user.userID;
function onRejectingBIR() {
loadConfirmDialog();
moveToCancel();
}
function loadConfirmDialog() {
//Display popup to capture reason for rejection.
var rejectconfirmDialog = new GlideModal('reject_approval_global');
rejectconfirmDialog.setTitle(new GwtMessage().getMessage("Rejection Reason:")); //Modify title to display on popup
rejectconfirmDialog.render();
}
// gsftSubmit(null, g_form.getFormElement(), "reject");
function moveToCancel(currentRec,currentUser) {
g_form.setValue("state", 11) //set state to Fix Implemented.
//Find the associated approval record and set it to rejected.
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', currentRec);
gr.addQuery('state','requested');
gr.addQuery('approver', currentUser);
gr.query();
while (gr.next()) {
gr.state = 'rejected';
gr.update();
}
setRedirect();
}
function setRedirect(current) {
current.update();
action.setRedirectURL(current);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 01:52 PM
I figured it out.
I moved the variables into the function, and they were able to finish the rejection.
function moveToCancel(currentRec,currentUser) {
currentRec = g_form.getUniqueValue();
currentUser = g_user.userID;
g_form.setValue("state", 11) //set state to Fix Implemented.
//Find the associated approval record and set it to rejected.
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', currentRec);
gr.addQuery('state','requested');
gr.addQuery('approver', currentUser);
gr.query();
while (gr.next()) {
gr.setValue('state','rejected');
gr.update()
}
setRedirect();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 11:13 AM - edited 01-28-2025 11:15 AM
Hi @Aaron Duncan ,
You can try passing the parameters explicitly
moveToCancel(currentRec, currentUser);
Also while setting the value:
gr.setValue('state', 'rejected');
current.update works on the server side, take a look at the last part of the function, if a save could do the job.
If my answer helped in any way, please mark it as ✅Correct & 👍Helpful
Regards,
Mahathi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 01:48 PM
@Mahathi none of the above worked. Any other ideas?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 01:52 PM
I figured it out.
I moved the variables into the function, and they were able to finish the rejection.
function moveToCancel(currentRec,currentUser) {
currentRec = g_form.getUniqueValue();
currentUser = g_user.userID;
g_form.setValue("state", 11) //set state to Fix Implemented.
//Find the associated approval record and set it to rejected.
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', currentRec);
gr.addQuery('state','requested');
gr.addQuery('approver', currentUser);
gr.query();
while (gr.next()) {
gr.setValue('state','rejected');
gr.update()
}
setRedirect();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 02:00 PM
Ok great @Aaron Duncan .
But still the value setting and current.update sure would've been helpful i feel.
Regards,
Mahathi