Onload client script to make filed readonly

Ashutosh Kumar4
Giga Contributor

I wrote client script to make some fields readonly if it is mobile view.

When i tested it on desktop by setting the mobile view it is working fine but when i tested it after connecting to the instance on mobile(handset). it is still showing as editable.

i used the below script:-

 

function onLoad() {
//Type appropriate comment here, and begin script below
var phase = g_form.getValue('u_phases'); //Fetching type of change

if(getView('mobile')){ //setting below fields as readonly only for mobile view
g_form.setReadonly('number',true);
g_form.setReadonly('type',true);
g_form.setReadonly('risk',true);
g_form.setReadonly('short_description',true);
g_form.setReadonly('start_date',true);
g_form.setReadonly('end_date',true);
g_form.setReadonly('u_uat_sign_off',true);
g_form.setReadonly('description',true);

}
}

Its working on desktop in mobile view but not after connecting instance on handset. Below is the screenshot

find_real_file.png

 

 

 

 

 

6 REPLIES 6

Hi Ashutosh Kumar,

Please mark my answer as correct and close the thread.

Shweta KHAJAPUR
Tera Guru

Try code as below,

function onLoad() {
//Type appropriate comment here, and begin script below
var phase = g_form.getValue('u_phases'); //Fetching type of change
  var view = getView();   
if(view =='mobile'){ //setting below fields as readonly only for mobile view
g_form.setReadonly('number',true);
g_form.setReadonly('type',true);
g_form.setReadonly('risk',true);
g_form.setReadonly('short_description',true);
g_form.setReadonly('start_date',true);
g_form.setReadonly('end_date',true);
g_form.setReadonly('u_uat_sign_off',true);
g_form.setReadonly('description',true);
g_form.setReadonly('u_maker',true);
g_form.setReadonly('u_checker',true);
g_form.setReadonly('u_tester',true);

}
}