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

Add this line after current.update() :

 action.setRedirectURL(current);

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

Thank you,
Abhishek Gardade

Hi Abhishek,

Not required to restart the workflow,as we are manually changing the state .

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

Thank you,
Abhishek Gardade

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