- 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 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 12:36 PM
Hi, sorry for my late answer...
So I finally wrote this code (client side + server side) but still get an error:
Uncaught TypeError: Cannot read property 'setAttribute' of null
I don't really know what's wrong with the code....
It definitely calls the client side function (I have the pop up question) but stop with the server side function and send me to the UI action form....
Thank you for your help
Onclick call the demoClientServerInv()
function demoClientServerInv()
{
var answer=confirm("Are you sure you want to approve this invoice?");
if(answer == true){
gsftSubmit(null, g_form.getFormElement(), 'sys_demoinvoice');
}
}
if (typeof window == 'undefined'){
updateRecord();
}
function updateRecord(){
//rec.addQuery('sysapproval', current.sys_id).addOrCondition('document_id', current.sys_id);
rec.addQuery('document_id', current.getUniqueValue());
rec.query();
if(rec.next()){
rec.state = 'approved';
rec.update();
}
action.setRedirectURL(current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2020 04:31 AM
Thank you for your Help!!!
My code finally gets to work thanks to you Ankur
And I leaned a lot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2020 04:54 AM
Glad to help.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader