- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 01:33 AM
Hi All,
I have one requirement as below,
Based on my workflow stage i need to make all fields readonly in one shot. But it should not make readonly on sys_created_on,sys_created_by,sys_updated_on and sys_updated_ by.
I have used the below code. But its making all fields including sys fields. Because of which i am getting error" "
var fields = g_form.getEditableFields();
for (var x=0; x < fields.length; x++){
g_form.setReadOnly(fields[x],true);
}
i need code where except these fields("sys_created_on,sys_created_by,sys_updated_on and sys_updated_ by.") everything should be readonly in one shot.
If possible please help me?
Thanks,
Malaisamy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 01:43 AM
You mean something like this is not enough?
for (var x=0; x < fields.length; x++){
if (fields[x] != 'sys_created_on' && fields[x] != 'sys_created_by' && fields[x] != 'sys_updated_on' && fields[x] != 'sys_updated_by')
g_form.setReadOnly(fields[x],true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2019 09:37 AM
Or we can get all the editable form fields and then make them read only via onload client script
function onLoad() {
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
// by default the mandatory fields can not be set as readonly
// Make the field non-mandatory before making it readonly
g_form.setMandatory(fields[x], false);
g_form.setReadOnly(fields[x], true);
}
}
Vinay Polisetti
Conyx IT Solutions | ServiceNow experts
vinay@conyxit.com