- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2017 07:00 AM
We have just started to use catalog task on some request items.
The problem we are having, is that the workflow changes the state as the process progresses which works fine.
But if a task is open and someone selects the Close Request Item UI Action ( Button) The RITM closes with the task still open.
After doing some research, I noticed a few other posts that I can't seem to get to work at all. I did try a business rule as mentioned in previous post but this does not appear to be working for me either.
Is there a way I can adjust the code of the button to check that the task is open and prompt the itil user to close the task that is assigned to them. If the customer closes the RITM, can the tasks be set to closed before the RITM is closed automatically via the workflow.
I am not sure how best to do this and my coding skills are pretty basic. Assistance if someone can help will be appreciated.
function closeRequestedItem(){
var response = confirm('Are you sure you want to close this requested item?');
if (!response)
return false;
//Set the 'State' values to 'Closed', and display mandatory fields
g_form.setValue('state', 3);
if (g_form.getValue('comments') == '') {
//Remove any existing field message, set comments mandatory, and show a new field message
try {g_form.hideFieldMsg('comments');} catch(e) {}
g_form.setMandatory('comments', true);
g_form.showFieldMsg('comments','Please enter comments and reselect Close Requested Item','error');
return false; //Abort submission
}
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'close_requested_item'); //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.state = 3;
current.update();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2017 08:07 AM
Here goes (works as expected on my sc_req_item table):
function closeRequestedItem(){
var response = confirm('Are you sure you want to close this requested item?');
if (!response)
return false;
//Set the 'State' values to 'Closed', and display mandatory fields
g_form.setValue('state', 3);
if (g_form.getValue('comments') == '') {
//Remove any existing field message, set comments mandatory, and show a new field message
try {g_form.hideFieldMsg('comments');} catch(e) {}
g_form.setMandatory('comments', true);
g_form.addErrorMessage('Please enter customer visible comments and reselect Close Requested Item','error');
//current.state = 1; //Set state to open --> commented this out
// g_form.setValue('state', 1); //Set state to open --> this too
return false;//Abort submission
}
// else{
// g_form.setValue('state', 3);
// current.update(); // --> this does not work on the client side
// }
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'close_requested_item'); //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.state = 3;
current.update();
}
//action.setRedirectURL(current); --> comment this out if you want to return to the records list
Do you have any BR running in the back, interfering with the update?
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2017 08:07 AM
Here goes (works as expected on my sc_req_item table):
function closeRequestedItem(){
var response = confirm('Are you sure you want to close this requested item?');
if (!response)
return false;
//Set the 'State' values to 'Closed', and display mandatory fields
g_form.setValue('state', 3);
if (g_form.getValue('comments') == '') {
//Remove any existing field message, set comments mandatory, and show a new field message
try {g_form.hideFieldMsg('comments');} catch(e) {}
g_form.setMandatory('comments', true);
g_form.addErrorMessage('Please enter customer visible comments and reselect Close Requested Item','error');
//current.state = 1; //Set state to open --> commented this out
// g_form.setValue('state', 1); //Set state to open --> this too
return false;//Abort submission
}
// else{
// g_form.setValue('state', 3);
// current.update(); // --> this does not work on the client side
// }
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'close_requested_item'); //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.state = 3;
current.update();
}
//action.setRedirectURL(current); --> comment this out if you want to return to the records list
Do you have any BR running in the back, interfering with the update?
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2017 08:17 AM
Thanks for the update. Appreciate the help on this.
It seems to be working, but if Customer Visible notes are not entered the state is closed and not set to open. So the customer will think the ticket is closed and it isn't.
Is there a way to change that in the code. I did try as you can see, it was changing to both states but not updating when the state was changed back to closed?
Sarah Muir | IT ServiceNow Technician
Norton Rose Fulbright LLP
3 More London Riverside, London, SE1 2AQ, United Kingdom
Tel +44 20 7444 3835 | Mob +44 7738 808219 | Fax +44 20 7283 6500
sarah.muir@nortonrosefulbright.com
NORTON ROSE FULBRIGHT
Law around the world
nortonrosefulbright.com<http://www.nortonrosefulbright.com>
Norton Rose Fulbright and Chadbourne & Parke have joined forces, giving our clients access to more than 4,000 lawyers worldwide.
nortonrosefulbright.com/chadbourne<http://www.nortonrosefulbright.com/chadbourne>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2017 08:22 AM
OK, yes.
Comment out line 6 "g_form.setValue('state', 3);" because it sets the state to close complete even though it does not save the form.
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2017 08:28 AM
I have commented out line 6
And the state changes to when the message shows. Perfect!
Enter Customer visible notes, State changes to Closed and exits the form back to the open requested item list view. Perfect!
But the Item state is still open and not closed in the list.
Open the record and it's set to open.
function closeRequestedItem(){
var response = confirm('Are you sure you want to close this requested item?');
if (!response)
return false;
//Set the 'State' values to 'Closed', and display mandatory fields
//g_form.setValue('state', 3);
if (g_form.getValue('comments') == '') {
//Remove any existing field message, set comments mandatory, and show a new field message
try {g_form.hideFieldMsg('comments');} catch(e) {}
g_form.setMandatory('comments', true);
g_form.addErrorMessage('Please enter customer visible comments and reselect Close Requested Item','error');
//current.state = 1; //Set state to open --> commented this out
// g_form.setValue('state', 1); //Set state to open --> this too
return false;//Abort submission
}
// else{
// g_form.setValue('state', 3);
// current.update(); // --> this does not work on the client side
// }
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'close_requested_item'); //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.state = 3;
current.update();
}
//action.setRedirectURL(current); --> comment this out if you want to return to the records list
Sarah Muir | IT ServiceNow Technician
Norton Rose Fulbright LLP
3 More London Riverside, London, SE1 2AQ, United Kingdom
Tel +44 20 7444 3835 | Mob +44 7738 808219 | Fax +44 20 7283 6500
sarah.muir@nortonrosefulbright.com
NORTON ROSE FULBRIGHT
Law around the world
nortonrosefulbright.com<http://www.nortonrosefulbright.com>
Norton Rose Fulbright and Chadbourne & Parke have joined forces, giving our clients access to more than 4,000 lawyers worldwide.
nortonrosefulbright.com/chadbourne<http://www.nortonrosefulbright.com/chadbourne>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2017 10:59 AM
Hi Sarah,
Did you solve this?
What happens if you uncomment the last line, close the record and re-open it?
harel