- 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-08-2019 11:58 PM
Hello Navya,
can you check the value for request state?
Also try adding logs in function to debug 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:03 AM
I have removed the request state and is working now.
But how can make RITM open on click of Reopen Button.
Can you suggest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2019 12:15 AM
I have modified your function as below:
function serverResolve(){
current.state = '1';
current.update();
// AFTER REOPENING REQUEST, HERE YOU CAN REOPEN RITM.
var gr= new GlideRecord('sc_req_item');
gr.addQuery('request', current.sys_id);
gr.query();
while(gr.next()){
gr.setValue('state' ,1); // here 1 is state value that you want to set. you can replace as you need
gr.update();
}
}
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:29 AM
Hello Navya,
What about the workflows of closed REQ/RITM? DO you also need to restart the workflow for REQ/RITM?
If you are reopening a REQ/RITM, then you should restart the workflow as well.
Your code Should be like :
function serverResolve(){
current.state = '1';
current.update();
new Workflow().restartWorkflow(current); // restart worklow for REQ
// AFTER REOPENING REQUEST, HERE YOU CAN REOPEN RITM.
var gr= new GlideRecord('sc_req_item');
gr.addQuery('request', current.sys_id);
gr.query();
while(gr.next()){
gr.setValue('state' ,1); // here 1 is state value that you want to set. you can replace as you need
gr.update();
}
new Workflow().restartWorkflow(gr); // restart worklow for RITM
}
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade