- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2024 03:43 PM
Currently, when I Close a Case by clicking on the Close Case button, I'm redirected to the previous place I accessed that Case from. For example, if I'm in Case list view and click on a Case from there, it opens the Case. When I close it, I'm returned back to the list view. If I'm already in a Case and I search for a different Case from the global search window, it opens the Case. When I close it, it returns me back to the previous Case I was in when I searched on the Case to close. I want to stay on the Case I closed, and not be redirected to the previous location I was at when I accessed the Case.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2024 10:43 PM
can you try this?
var grCT = new GlideRecord("sn_customerservice_task");
grCT.addQuery("parent", current.sys_id);
grCT.addQuery("active", true);
grCT.query();
if (grCT.next()) {
gs.addErrorMessage("You cannot Resolve or Close a Case with open Tasks");
//current.setAbortAction(true);
} else {
new global.StateFlow().processFlow(current, 'd8069501c33231005f76b2c712d3aead', 'manual');
//if current user is the case caller, redirect the user to survey
if (current.contact == gs.getUserID()) {
//The executed triggerCondition sys_id
var TriggerConditionId = "97a9bec1c37231005b2c7bfaa2d3ae33";
//The assessment sys_id in the executed triggerCondition
var assessmentType = "a0dfbc85c33231001b757bfaa2d3aee7";
var assessmentSysId;
var gr = new GlideRecord("asmt_assessment_instance");
gr.addQuery("trigger_condition", TriggerConditionId);
gr.addQuery("user", current.contact);
gr.addQuery("state", "ready");
gr.addQuery("trigger_id", current.sys_id);
gr.query();
if (gr.next()) {
assessmentSysId = gr.getValue("sys_id");
if (!gs.nil(assessmentSysId)) {
var url = '/assessment_take2.do?sysparm_assessable_type=' + assessmentType + '&sysparm_assessable_sysid=' + assessmentSysId;
action.setRedirectURL(url);
}
}
} else {
// Stay on the same page after closing the case
action.setRedirectURL(current);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2024 09:36 AM
Also, what did you add to the code I provided?
Just?:
} else {
// Stay on the same page after closing the case
action.setRedirectURL(current);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2024 12:33 PM
ar grCT = new GlideRecord("sn_customerservice_task");
grCT.addQuery("parent", current.sys_id);
grCT.addQuery("active", true);
grCT.query();
if(grCT.next()) {
gs.addErrorMessage("You cannot Resolve or Close a Case with open Tasks");
//current.setAbortAction(true);
} else {
new global.StateFlow().processFlow(current, 'd8069501c33231005f76b2c712d3aead', 'manual');
//if current user is the case caller, redirect the user to survey
if(current.contact == gs.getUserID()){
//The executed triggerCondition sys_id
var TriggerConditionId = "97a9bec1c37231005b2c7bfaa2d3ae33";
//The assessment sys_id in the executed triggerCondition
var assessmentType = "a0dfbc85c33231001b757bfaa2d3aee7";
var assessmentSysId;
var gr = new GlideRecord("asmt_assessment_instance");
gr.addQuery("trigger_condition", TriggerConditionId);
gr.addQuery("user", current.contact);
gr.addQuery("state","ready");
gr.addQuery("trigger_id",current.sys_id);
gr.query();
if(gr.next()){
assessmentSysId = gr.getValue("sys_id");
if(!gs.nil(assessmentSysId)) {
var url = '/assessment_take2.do?sysparm_assessable_type='+assessmentType+'&sysparm_assessable_sysid='+assessmentSysId;
action.setRedirectURL(url);
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2024 05:06 PM
This line should be at the end of the script.
action.setRedirectURL(current);
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2024 09:16 PM
I did update the last line with action.setRedirectURL(current);
but it didn't work. I'm seeing the same behavior. The screenshot is after I changed it back.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2024 10:43 PM
can you try this?
var grCT = new GlideRecord("sn_customerservice_task");
grCT.addQuery("parent", current.sys_id);
grCT.addQuery("active", true);
grCT.query();
if (grCT.next()) {
gs.addErrorMessage("You cannot Resolve or Close a Case with open Tasks");
//current.setAbortAction(true);
} else {
new global.StateFlow().processFlow(current, 'd8069501c33231005f76b2c712d3aead', 'manual');
//if current user is the case caller, redirect the user to survey
if (current.contact == gs.getUserID()) {
//The executed triggerCondition sys_id
var TriggerConditionId = "97a9bec1c37231005b2c7bfaa2d3ae33";
//The assessment sys_id in the executed triggerCondition
var assessmentType = "a0dfbc85c33231001b757bfaa2d3aee7";
var assessmentSysId;
var gr = new GlideRecord("asmt_assessment_instance");
gr.addQuery("trigger_condition", TriggerConditionId);
gr.addQuery("user", current.contact);
gr.addQuery("state", "ready");
gr.addQuery("trigger_id", current.sys_id);
gr.query();
if (gr.next()) {
assessmentSysId = gr.getValue("sys_id");
if (!gs.nil(assessmentSysId)) {
var url = '/assessment_take2.do?sysparm_assessable_type=' + assessmentType + '&sysparm_assessable_sysid=' + assessmentSysId;
action.setRedirectURL(url);
}
}
} else {
// Stay on the same page after closing the case
action.setRedirectURL(current);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2024 09:34 AM
Yes, this worked.
We have a field on our Case called Product Name (u_product_name). Is it possible to update/change this code, to only stay on the Case when closed, if the Product Name is a specific value? For example, Product Name on the Case is 'Widget'. When clicking on the 'Close Case' button and Product Name is 'Widget', then stay on the Case when it's closed. If not, then continue the current behavior when the Case is closed.
