How to remove Resolution Notes mandatory from case record

Gopal14
Tera Contributor

Hi Team,

 

I want to remove mandatory from Resolution Notes when we are closing or resolving the case.

 

I just want Resolution Code to be mandatory.

 

I guess we have a UI Policy and Client Script.

 

UI Policy:

Below is the UI Policy,

 

Gopal14_0-1747924561586.png

 

On this UI Policy I just made mandatory to Leave Alone

 

 

Client Script: 

 

function onSubmit() {
	var submitAction = g_form.getActionName();
	//If "Close Case" or "Propose Solution" actions are triggered
	if(submitAction == "close" || submitAction == "proposeSolution"){
		
		if(submitAction == "close" && g_form.hasField("closed_by"))
			g_form.setValue('closed_by', g_user.userID, g_user.userName);
		
		if(submitAction == "proposeSolution" && g_form.hasField("resolved_by"))
			g_form.setValue('resolved_by', g_user.userID, g_user.userName);
		
		//Validate if Close Notes & Resolution Code are populated
		if((g_form.hasField("close_notes") && g_form.getValue("close_notes") == "") || (g_form.hasField("resolution_code") && g_form.getValue("resolution_code") == "")){
			if(submitAction == "proposeSolution"){
				g_form.addErrorMessage(getMessage('To propose a solution, you must select a resolution code'));
			//	g_form.addErrorMessage(getMessage('To propose a solution, you must select a resolution code and add resolution notes.'));
			}else{
                g_form.addErrorMessage(getMessage('To close a case, you must select a resolution code'));
			//	g_form.addErrorMessage(getMessage('To close a case, you must select a resolution code and add resolution notes.'));
			}
			if(typeof g_tabs2Sections !== 'undefined'){
				var tabIndex = g_tabs2Sections.findTabIndex('close_notes');
				if(tabIndex > -1){
					g_tabs2Sections.setActive(tabIndex);
					g_tabs2Sections.markTabMandatoryByField('close_notes'); 
				}
			}
		//	g_form.hideFieldMsg('close_notes');
			g_form.hideFieldMsg('resolution_code');
			
			if(g_form.getValue("resolution_code") == ""){
				g_form.showFieldMsg('resolution_code', getMessage('Resolution code is required.'), 'error', false);
			}
		/*	if(g_form.getValue("close_notes") == ""){
				g_form.showFieldMsg('close_notes', getMessage('Resolution notes are required.'), 'error', false);
			} */
			return false;
		}
	}
}

 

whatever is there in the comments, I have commented that for making resolution notes as non mandatory.

 

The result, when I am closing the case It is not showing as mandatory for Resolution Notes, However, it is not allowing to submit the case, it is showing below error message

 

Gopal14_1-1747924792852.png

Even I have selected Resolution code, but still it is showing the same

 

Any help what I am doing wrong

1 ACCEPTED SOLUTION

Chaitanya ILCR
Kilo Patron

Hi @Gopal14 ,

function onSubmit() {
    var submitAction = g_form.getActionName();
    //If "Close Case" or "Propose Solution" actions are triggered
    if (submitAction == "close" || submitAction == "proposeSolution") {

        if (submitAction == "close" && g_form.hasField("closed_by"))
            g_form.setValue('closed_by', g_user.userID, g_user.userName);

        if (submitAction == "proposeSolution" && g_form.hasField("resolved_by"))
            g_form.setValue('resolved_by', g_user.userID, g_user.userName);

        //Validate if Close Notes & Resolution Code are populated
        if ( /*(g_form.hasField("close_notes") && g_form.getValue("close_notes") == "") ||commented this*/ (g_form.hasField("resolution_code") && g_form.getValue("resolution_code") == "")) {
            if (submitAction == "proposeSolution") {
                g_form.addErrorMessage(getMessage('To propose a solution, you must select a resolution code'));
                //	g_form.addErrorMessage(getMessage('To propose a solution, you must select a resolution code and add resolution notes.'));
            } else {
                g_form.addErrorMessage(getMessage('To close a case, you must select a resolution code'));
                //	g_form.addErrorMessage(getMessage('To close a case, you must select a resolution code and add resolution notes.'));
            }
            /*
			commented this if block too but you can enable it if you want from 21 to 30
            if (typeof g_tabs2Sections !== 'undefined') {
                var tabIndex = g_tabs2Sections.findTabIndex('close_notes');
                if (tabIndex > -1) {
                    g_tabs2Sections.setActive(tabIndex);
                    g_tabs2Sections.markTabMandatoryByField('close_notes');
                }
            }
			*/
            //	g_form.hideFieldMsg('close_notes');
            g_form.hideFieldMsg('resolution_code');

            if (g_form.getValue("resolution_code") == "") {
                g_form.showFieldMsg('resolution_code', getMessage('Resolution code is required.'), 'error', false);
            }
            /*	if(g_form.getValue("close_notes") == ""){
            		g_form.showFieldMsg('close_notes', getMessage('Resolution notes are required.'), 'error', false);
            	} */
            return false;
        }
    }
}

 

update your client script with above script 

I have added comments the line where I have commented

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

View solution in original post

4 REPLIES 4

Chaitanya ILCR
Kilo Patron

Hi @Gopal14 ,

function onSubmit() {
    var submitAction = g_form.getActionName();
    //If "Close Case" or "Propose Solution" actions are triggered
    if (submitAction == "close" || submitAction == "proposeSolution") {

        if (submitAction == "close" && g_form.hasField("closed_by"))
            g_form.setValue('closed_by', g_user.userID, g_user.userName);

        if (submitAction == "proposeSolution" && g_form.hasField("resolved_by"))
            g_form.setValue('resolved_by', g_user.userID, g_user.userName);

        //Validate if Close Notes & Resolution Code are populated
        if ( /*(g_form.hasField("close_notes") && g_form.getValue("close_notes") == "") ||commented this*/ (g_form.hasField("resolution_code") && g_form.getValue("resolution_code") == "")) {
            if (submitAction == "proposeSolution") {
                g_form.addErrorMessage(getMessage('To propose a solution, you must select a resolution code'));
                //	g_form.addErrorMessage(getMessage('To propose a solution, you must select a resolution code and add resolution notes.'));
            } else {
                g_form.addErrorMessage(getMessage('To close a case, you must select a resolution code'));
                //	g_form.addErrorMessage(getMessage('To close a case, you must select a resolution code and add resolution notes.'));
            }
            /*
			commented this if block too but you can enable it if you want from 21 to 30
            if (typeof g_tabs2Sections !== 'undefined') {
                var tabIndex = g_tabs2Sections.findTabIndex('close_notes');
                if (tabIndex > -1) {
                    g_tabs2Sections.setActive(tabIndex);
                    g_tabs2Sections.markTabMandatoryByField('close_notes');
                }
            }
			*/
            //	g_form.hideFieldMsg('close_notes');
            g_form.hideFieldMsg('resolution_code');

            if (g_form.getValue("resolution_code") == "") {
                g_form.showFieldMsg('resolution_code', getMessage('Resolution code is required.'), 'error', false);
            }
            /*	if(g_form.getValue("close_notes") == ""){
            		g_form.showFieldMsg('close_notes', getMessage('Resolution notes are required.'), 'error', false);
            	} */
            return false;
        }
    }
}

 

update your client script with above script 

I have added comments the line where I have commented

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

HI @Chaitanya ILCR ,

 

 

As per your comments I have updated my script,

 

Now I am receiving this error 

 

Gopal14_0-1747928139875.png

 

Hi @Gopal14 ,

Check if there is any BR or within UI action any other functionality which is throwing that error

 

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Hey Chaitanya,

I had the same issue.

You also have to modify the Script in the State Flows for the Case table. For Resolved State and Close State. 

Swetlana_0-1752570737033.png