Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2013 08:52 AM
I forgot to increment x in the loop. Here is a revision:
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id',current.sys_id);
gr.query();
gs.print('Found ' + gr.getRowCount() + ' records.');
var x = 1;
while (gr.next()) {
gs.print(x + " - Approver : " + gr.approver.getDisplayValue() + ", State : "+ gr.state );
if (gr.state == 'Request Approval') { // make sure this is the real value
gs.print(x + " - Changing to requested.");
gr.state = 'requested';
gr.update();
}
gs.print(x + " - gr.sys_id : "+gr.sys_id );
x++;
}
current.u_mr_state = '2';
current.approval='requested';
current.update();
action.setRedirectURL(current);