I need to implement "Reopen" button on the request form.

Navyaa
Tera Expert

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 !!

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

18 REPLIES 18

Hi,

Action name would be used only when you want use the UI action both client + server

but here only keeping server side code is helping you achieve your requirement

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I am using the same code with your comments, but still no luck.

Hi,

So is RITM getting opened?

Is request getting opened?

What is not happening?

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Besides of the technical aspect, a lot of input is given in this thread already, what about the functional side? I mean, you could reopen a Request, Requested Item. Though, maybe already approvals have been given, tasks have been executed, the workflow already finished.

What about these?

Or should the workflow also be started again, from the start? Or somewhere in the middle?

Technically reopening the Request or Requested Item is a piece of cake. But functionally???

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn