How to force the agent to fill mandatory fields when he closes [X] the incident record in SOW?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2024 08:07 AM
SOW: Agents are accidentally clicking "create incident" from interaction and closing the incident tab by clicking the [X] icon. We need to prompt for mandate before closing. So, I am trying to save the record before the user closes it. I tried the below script but the window.onbeforeunload does not work in sow workspace. So, what is the best way to accomplish this?
function onLoad() {
var url = top.location.href;
if (url.indexOf('now/sow/record/interaction/')) {
window.onbeforeunload = function() {
//alert("Please fill out mandatory fields.");
g_form.save().then(function() {
g_aw.closeRecord();
});
};
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2024 09:35 AM
I think that the code that you propose seems correct. The only thing that is puzzling me is why is this a Client Script with onLoad? You are saying: "If the page loads and it's unloading, then alert" which will never be true..
In the same time this requirement will flood your system with a ton of "fake" incidents. This makes me question the requirement that you have...
Solution wise, there is something that you can do - insert the request onLoad of the page. Then onChange you can update the record with it's respective value just as the user modifies it in the UI but still display it as a new record on the form. Once the user submits, you would need to just prevent insert if the record already exists...
Hope this feedback is helpful