Reference fields are disabled when using UI policies

Yuki21
Tera Expert

Hello.
Implemented a script to deactivate a screen field in case of certain status in UI policy.

I have a field in my script that I don't want to deactivate, but I'm using exception handling,
but the reference field button doesn't work.
What is the cause?

<UI policy>

find_real_file.png

find_real_file.png

<UI policy Script>

function onCondition() {
//必要に応じて条件を挿入
        var notReadOnly = ["u_choice_3","u_shounin_user_id","u_shounin_pw","u_sekininsha_user_id","u_sekininsha_pw","request"];
        var fields = g_form.getEditableFields();  //フォームの編集可能フィールを取得
        for (var x = 0; x < fields.length; x++) {
            if(notReadOnly.indexOf(fields[x]) == -1){
                g_form.setMandatory(fields[x], false);  //必須を無効にする
                g_form.setReadOnly(fields[x], true);    //読取り専用にする
            }
        }
	g_form.setReadOnly("variables."+ req_category_1, true);
	g_form.setReadOnly("variables."+ req_category_2, true);
	g_form.setReadOnly("variables."+ req_category_3, true);
	g_form.setReadOnly("variables."+ req_category_4, true);
	g_form.setReadOnly("variables."+ req_category_5, true);
	g_form.setReadOnly("variables."+ req_device_1, true);
	g_form.setReadOnly("variables."+ req_device_2, true);
	}

<problem screen>
find_real_file.png

1 ACCEPTED SOLUTION

Arav
Tera Guru
Tera Guru

Hi,

Please check the community article below.

https://community.servicenow.com/community?id=community_question&sys_id=d570c3e1db98dbc01dcaf3231f96192e

You can enable it by setting property "glide.ui.reference.readonly.clickthrough" to true.

Thanks,

Arav

View solution in original post

7 REPLIES 7

Yuki21
Tera Expert

It is under investigation, but after commenting out the following processing in the script, the reference button can now be pressed.
However, what I'm making ReadOnly below is a different field than the reference field.
The requirement to make the fields of variables. ReadOnly is necessary.
I don't know why it affects me...

    g_form.setReadOnly("variables."+ req_category_1, true);
    g_form.setReadOnly("variables."+ req_category_2, true);
    g_form.setReadOnly("variables."+ req_category_3, true);
    g_form.setReadOnly("variables."+ req_category_4, true);
    g_form.setReadOnly("variables."+ req_category_5, true);
    g_form.setReadOnly("variables."+ req_device_1, true);
    g_form.setReadOnly("variables."+ req_device_2, true);

Hi,

What are "req_category_1", "req_category_2" etc. ? Are these catalog variable names ?

If so, then please change

    g_form.setReadOnly("variables."+ req_category_1, true);

to

    g_form.setReadOnly("variables.req_category_1", true);

and try.

Thanks,

Arav

Thank you very much for your advice.
I solved it with a client script.
Implemented in olLoad