- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2020 01:30 AM
Hi everyone,
I need to add a button in a form.
the user see the record he can approve or reject.
I am new to servicenow and I am not really sure of how to do it.
Thanks for your help
Juliette
Solved! Go to Solution.
- Labels:
-
User Experience and Design
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2020 03:37 AM
Hi,
got it
Try this code in the UI action of Approve on your custom Table; It should be server side
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();
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2020 01:38 AM
Hi,
You will have to create Form UI Action
Condition: gs.getUserID() == current.approver_field
This will allow them to see the button only if the logged in user is approver
In the script section set the state to Approve/Reject based on your UI Action and then update the record
Refer OOB UI Actions Approve and Reject on sysapproval_approver table
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2020 01:51 AM
Thank you for your Answer Ankur Bawiskar but I am not really a developer and not used to write any script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2020 02:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2020 03:26 AM
Thank you for your second answer, the thing is the approve action are set inside the approval table... my button is inside another table and when we click the button, we need to change the requested state of the approval in the sys_approval table in Approved.... Is it possible??
Thank you again
Best Regards
Juliette