Client script to hide fields

Koki
Tera Contributor

I have tried the following script with no success.

I want to hide the field in the attachment that is circled in red.

Is there something wrong in the way I'm writing it?

 

function onLoad() {

 if (g_user.hasRoleExactly('x_540069_cmdb.test_roll1')) {

  g_form.setVisible('kisyu_name', true);
  g_form.setVisible('gyousya_name', true);
 }
 else {
  g_form.setVisible('kisyu_name', false);
  g_form.setVisible('gyousya_name', false);
 }
}

1 ACCEPTED SOLUTION

Anil Lande
Kilo Patron

I see you have added fields from one your reference field by dot walking.

To manage dot walked fields use below logic:

 

function onLoad() {

 if (g_user.hasRoleExactly('x_540069_cmdb.test_roll1')) {

  g_form.setVisible('kisyu_name', true);
  g_form.setVisible('kisyu_name.maker_id.gyousya_name', true);
 }
 else {
  g_form.setVisible('kisyu_name', false);
  g_form.setVisible('kisyu_name.maker_id.gyousya_name', false);
 }

always use field name in client script and if it is dot walked field then use highlighted part:

find_real_file.png

 

 

Thanks,

Anil Lande

View solution in original post

7 REPLIES 7

Koki
Tera Contributor

I'm sorry every time.

 

The Field watcher showed only a 3-line ACL.

I am not sure what these three lines represent.

find_real_file.png

Koki
Tera Contributor

Hi,

 

It was successful.

It seems that the definition of the field name was wrong.

I made a rudimentary oversight, sorry.

 

However, it was very helpful and I learned a lot from your detailed instructions!


Thank you very much.

You are welcome!

 

Stay Safe and Happy Learning 🙂

Anil Lande