UI Action button for Approve on a form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2022 09:24 AM
Hi All,
I have a requirement to add an Approve button to a form. The records related to this form require an approval from two users before the approval state moves to approved. I have added a UI Action to create the Approval button on the form with the following script:
action.setRedirectURL(current);
current.update();
updateRecord();
function updateRecord(){
var rec = new GlideRecord('sysapproval_approver');
rec.addQuery('sysapproval', current.sys_id).addOrCondition('document_id', current.sys_id);
rec.query();
if(rec.next()){
rec.state = 'approved';
rec.update();
}
}
The approval button works fine for the first user that approves but when the second user approves the approval state for the second user does not update and remains in a Requested state.
If anyone has an idea why this is happening and how to resolve it I would be very appreciative!
Regards,
Ross
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 01:27 AM
Just add additional query for state.