- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 07:30 AM
I want to make all fields read only of a table using client script but it has a lot of fields so it is very time consuming using g_form.setReadOnly().So is there any other way to do that?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 08:41 AM
Hi Anish,
Try this :
function onLoad() {
var StrQry='';
var fieldname = '';
var gr = new GlideRecord('sys_dictionary');
StrQry="name=incident"; //change the table name ,for example I used 'incident', and also you can add more query here.
gr.encodedQuery = StrQry;
gr.query();
while(gr.next()){
fieldname=gr.element;
g_form.setReadOnly(fieldname,true);
}
}
Thanks,
Farukh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 08:29 AM
function onLoad(){
try{
//Get the 'Variables' section
var ve = $('variable_map').up('table');
//Disable all elements within with a class of 'cat_item_option'
ve.select('.cat_item_option', '.slushselectmtm', '.questionsetreference', '.form-control', '.checkbox').each(function(elmt){
elmt.disabled = true;
});
//Remove any reference or calendar icons
ve.select('img[src*=reference_list.gifx]', 'img[src*=small_calendar.gifx]').each(function(img){
img.hide();
});
//Hide list collector icons
ve.select('img[src*=arrow]').each(function(img){
img.up('table').hide();
});
}
catch(e){}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2017 05:47 AM
Hi Deepak,
just FYI, if you recommend this script to someone, could you please also add that this will not be supported by ServiceNow Customer Support as we actively discourage our customers from using DOM manipulation? Please see ServiceNow KB: Date Variable values change when saving a record that includes the Variable Editor, i... for more information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 08:41 AM
Hi Anish,
Try this :
function onLoad() {
var StrQry='';
var fieldname = '';
var gr = new GlideRecord('sys_dictionary');
StrQry="name=incident"; //change the table name ,for example I used 'incident', and also you can add more query here.
gr.encodedQuery = StrQry;
gr.query();
while(gr.next()){
fieldname=gr.element;
g_form.setReadOnly(fieldname,true);
}
}
Thanks,
Farukh