Comments on: Readonly Variables on a Standard Form https://servicenowguru.com/client-scripts-scripting/variables-form-readonly/ ServiceNow Consulting Scripting Administration Development Tue, 28 May 2024 21:20:54 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Dinesh Chinnadurai https://servicenowguru.com/client-scripts-scripting/variables-form-readonly/#comment-7121 Tue, 14 Mar 2017 15:39:38 +0000 https://servicenowguru.wpengine.com/?p=1706#comment-7121 Thanks Mark!

BR helped me restrict write from the variables.

]]>
By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/variables-form-readonly/#comment-7120 Fri, 10 Mar 2017 13:33:07 +0000 https://servicenowguru.wpengine.com/?p=1706#comment-7120 In reply to kirti.

You could try something like this if you want to use the traditional client script method…
https://community.servicenow.com/message/799314#799314

I think that going forward you might consider the ‘Ticket Fields’ service portal widget instead. That shows all of the variables by default in a readonly form.

]]>
By: kirti https://servicenowguru.com/client-scripts-scripting/variables-form-readonly/#comment-7119 Fri, 10 Mar 2017 04:48:15 +0000 https://servicenowguru.wpengine.com/?p=1706#comment-7119 HI Mark,

This doesn’t seem to work in Service Portal.
Any thoughts?

Thanks and Regards,
Kirti

]]>
By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/variables-form-readonly/#comment-7118 Fri, 02 Sep 2016 19:21:03 +0000 https://servicenowguru.wpengine.com/?p=1706#comment-7118 In reply to Kristen.

Looks like the class names on those variable types have changed slightly. I’ve updated the script above with something that should work. Give it a try and let me know how it goes.

]]>
By: Kristen https://servicenowguru.com/client-scripts-scripting/variables-form-readonly/#comment-7117 Fri, 02 Sep 2016 18:48:19 +0000 https://servicenowguru.wpengine.com/?p=1706#comment-7117 Hi Mark,

I had put this into our environment and it was working great, but we have a form with checkboxes and list collectors and it’s showing them as editable, not read only. I’m not sure why and was wondering if you might have an idea?

thanks!

]]>
By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/variables-form-readonly/#comment-7116 Thu, 01 Sep 2016 13:30:43 +0000 https://servicenowguru.wpengine.com/?p=1706#comment-7116 In reply to Abu.

Only think I can say is to copy the code exactly. One thing to note is the variable name ‘elmt’, not ‘elmnt’ as you have in this comment.

]]>
By: Abu https://servicenowguru.com/client-scripts-scripting/variables-form-readonly/#comment-7115 Tue, 30 Aug 2016 11:09:45 +0000 https://servicenowguru.wpengine.com/?p=1706#comment-7115 Hi Mark, I have modified the code with elmnt.readOnly = true. I can see the date resetting is fixed but still i can see the dropdown variables are editable here. Please provide some advice.

]]>
By: David https://servicenowguru.com/client-scripts-scripting/variables-form-readonly/#comment-7114 Wed, 16 Mar 2016 18:05:27 +0000 https://servicenowguru.wpengine.com/?p=1706#comment-7114 Hello,
Viewing this post got me thinking if it will be possible somehow to pass down all the variables or variable set from an “Order Guide” to the request form? Maybe in a tab? Let me know if it is possible. Thanks!

]]>
By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/variables-form-readonly/#comment-7113 Thu, 03 Mar 2016 00:54:51 +0000 https://servicenowguru.wpengine.com/?p=1706#comment-7113 In reply to Johnny W.

Make sure that the ‘elmt.Disabled’ line looks like this (including the proper case)…

elmt.disabled = true;

If that doesn’t work then you can try ‘elmt.readOnly = true;’.

]]>
By: Johnny W https://servicenowguru.com/client-scripts-scripting/variables-form-readonly/#comment-7112 Wed, 02 Mar 2016 21:30:49 +0000 https://servicenowguru.wpengine.com/?p=1706#comment-7112 In reply to Mark Stanger.

I’ve used the client script code provided and it is still resetting my date variables. Based on Mark’s fix, the code should now be fixed to use ‘readOnly’ instead of ‘disabled’. However, I’m not seeing ‘readOnly’ anywhere in his script. Am I missing something?

Here is what I have:

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’).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){}
}

]]>