Onload client script to make filed readonly

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2018 11:47 PM
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
- Labels:
-
Field Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2018 10:45 PM
Hi Ashutosh Kumar,
Please mark my answer as correct and close the thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2018 12:06 AM
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);
}
}