Client Script (g_form.setDisplay) not working in Agent Workspace

Hyohyeon Kim
Tera Contributor

Hi Experts.

I've launch my Client Script in production, but suddenly it something went wrong.

UI Type: All

Isolate script: True

onChange script:

Script returns response and alert() also working, but g_form.setDisplay() only does not work.

*It works in Platform UI

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var ga = new GlideAjax('GetChoiceValueInCSM');
    ga.addParam('sysparm_name', 'getChoiceByDependentValue');
    ga.addParam('sysparm_element', 'u_third_category');
    ga.addParam('sysparm_dependentvalue', g_form.getValue('subcategory'));
    ga.addParam('sysparm_tablename', 'sn_customerservice_case');
    ga.getXMLAnswer(getChoices);

    function getChoices(response) {
        if (response) {
			g_form.setDisplay('u_third_category', true);
			alert("!!");
        } else {
            g_form.setDisplay('u_third_category', false);
			alert("!!22");
		}
    }
}

I can't even guess the cause. How can I fix it?

 

Regards.

 

1 ACCEPTED SOLUTION

Hyohyeon Kim
Tera Contributor

Dear Respondents

The cause of this issue has been identified.
The problem wasn't the script. The cause was that the Workspace View Rule did not show the field.

Thank you for your cooperation.

View solution in original post

7 REPLIES 7

Musab Rasheed
Tera Sage
Tera Sage

Hello,

I have read about Client script not working properly when using dependent values specially when adding/removing choices but your case seems to be different but can you try with setVisible instead of setDisplay.? Also add alert above set function.

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Hi, @Musab Rasheed 

I've tried setVisible instead, but it does not work also.

Regards

Hyohyeon Kim
Tera Contributor

Dear Respondents

The cause of this issue has been identified.
The problem wasn't the script. The cause was that the Workspace View Rule did not show the field.

Thank you for your cooperation.