- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2015 02:54 AM
Hi All,
Could you please help me in how to know whether a particular field is Read only or not from Client Script. Like i want to know whether a field "request_state" is read only or not in sc_request table from script.
Thanks and Regards
Lohith.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2016 02:57 AM
Hello,
We found a solution to this problem by inspecting the form HTML. For every field on the form ServiceNow generates a status span that keeps track of the current field input status. When the field is set to read-only, either by the server or through a client script, this field has the class 'read_only'. Therefore we use the following function to check if a field is readonly:
function( fieldname ) {
var elem = document.getElementById( 'status.' + g_form.getTableName() + '.' + fieldname );
return elem.hasClassName( 'read_only' );
}
Hope this helps!
Joris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2015 03:06 AM
HI,
You might need to do some research as to how the html attributes are set when a field is marked read only.
then using g_form.getControl() function you should be able to read that attribute and decide whether the field is marked readonly or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2016 02:57 AM
Hello,
We found a solution to this problem by inspecting the form HTML. For every field on the form ServiceNow generates a status span that keeps track of the current field input status. When the field is set to read-only, either by the server or through a client script, this field has the class 'read_only'. Therefore we use the following function to check if a field is readonly:
function( fieldname ) {
var elem = document.getElementById( 'status.' + g_form.getTableName() + '.' + fieldname );
return elem.hasClassName( 'read_only' );
}
Hope this helps!
Joris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2017 01:39 PM
Hi,
I know you posted this some time ago, but I was wondering if this is still use able in Helsinki and how I might implement it.
I'm trying to have it lookup the value of a field titled u_asset_tag but so far in all my efforts have been unable to return a value?
Any help is greatly appreciated.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2015 03:22 AM
Hi Lohith,
I think you can not get to know that within the client script.
As the fields are made read only in client side code and the client script in which you want to determine weather the field is read only or not, will also run on the client.
And more over the fields become read-only only after the form gets rendered, and at that time all the client side execution are already completed.
Regards
Pratul Agarwal