- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2019 11:51 PM
Hi All,
I have requirement, where I need to implement the "Reopen" button on the request form.
I have the below UI Action :
Form Button : True
Action name: reopen_request
Client : True
Show Update : True
Show Insert : True
Onclick : reopenRequest()
function reopenRequest(){
//Set the 'Incident state' and 'State' values to 'Resolved', and display mandatory fields
g_form.setValue('request_state', in_process);
g_form.setValue('state',1);
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(),'reopen_request'); //MUST call the 'Action name' set in this UI Action
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
serverResolve();
function serverResolve(){
current.request_state = 'in_process';
current.state = '1';
current.update();
}
Please anyone can help on this !!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2019 12:04 AM
Hi,
you can have it as server side code and don't require client side for this; remove the client checkbox and function name
serverResolve();
function serverResolve(){
// get all RITMs for this request and update them to open then mark request state as open
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', current.sys_id);
ritm.query();
while(ritm.next()){
ritm.state = '1';
ritm.update();
}
current.request_state = 'in_process';
current.state = '1';
current.update();
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
09-09-2019 12:45 AM
Hi Abhishek,
When I added the following line then the request state changed to open
current.request_state='in_process';
But the page is not staying the request form,but its getting redirected to a different page.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2019 12:47 AM
Add this line after current.update() :
action.setRedirectURL(current);
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2019 12:47 AM
Hi Abhishek,
Not required to restart the workflow,as we are manually changing the state .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2019 12:48 AM
Okay Cool,
action.setRedirectURL(current); to stay on current form of REQUEST
Reference:
https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2019 12:04 AM
Hi,
you can have it as server side code and don't require client side for this; remove the client checkbox and function name
serverResolve();
function serverResolve(){
// get all RITMs for this request and update them to open then mark request state as open
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', current.sys_id);
ritm.query();
while(ritm.next()){
ritm.state = '1';
ritm.update();
}
current.request_state = 'in_process';
current.state = '1';
current.update();
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader