Hi All,
I have a custom field called 'Completed On' in a Case entity. When a user clicks the Resolve Case button, I want to prevent the Case from Resolving if my custom field isn't populated. I can't make it mandatory because it should be completed by the user only when the case is completed.
I have managed to do this in part except that the message is only displayed after the Case Resolution form is completed. Is there any way to get my alert to show prior to the Case Resolution form? Below is the code I am presently using.
Regards,
Dan
function ValidateCompletedOn(prmContext) { // Local variable to store value indicating how the save event was initiated by the user. var wod_SaveMode, wod_SaveEventVal; // Change the Save Event Value as per required Save Event wod_SaveEventVal = 5; if (prmContext != null && prmContext.getEventArgs() != null) { wod_SaveMode = prmContext.getEventArgs().getSaveMode(); // 1 will pass on Recalculate button click if (wod_SaveMode == wod_SaveEventVal) { // Write your validation code here var table = document.getElementById("cscdb_completedon"); var td = table.getElementsByTagName("td")[0]; var input = td.getElementsByTagName("input")[0]; var resolved = input.value; if(resolved.length != 0){ if (confirm('Have you checked that the subject and contract are set accurately?')){ return true; } } else { alert('Please provide the date when the case was completed on.'); prmContext.getEventArgs().preventDefault(); } // Use the code line below only if validation is failed then abort function save event prmContext.getEventArgs().preventDefault(); } } }