- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 02:43 AM
Hi All,
Could you please help me with the following scenario:
We have to make certain fields of the change request read only for standard type change. The field values are populated based on the Standard change template (values are stored in the table std_change_template). If the value is autopopulated from template then we have to make read only. Otherwise the filed should be editable.
Thank you
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 03:08 AM
Please give it a try and let me know.
If I have answered your question, please mark my response as correct and helpful so that this thread can be closed and others can be benefited by this.
Thank you very much
Cheers
Alberto

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 02:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 02:59 AM
There are 2 fields 1. Mandatory on dictionary level 2. Nonmandatory
will the above workaround resolve the issue?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 03:08 AM
Please give it a try and let me know.
If I have answered your question, please mark my response as correct and helpful so that this thread can be closed and others can be benefited by this.
Thank you very much
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 03:17 AM
The exisitnd client script to make fields read only is ;
function onLoad() {
var chgType = g_form.getValue("type");
var ga;
if (chgType == "standard") {
if (g_form.isNewRecord() || g_form.getUniqueValue() === -1 || g_form.getUniqueValue() === '-1'){
ga = new GlideAjax('StdChangeUtils');
ga.addParam('sysparm_name', 'ajaxFunction_getReadOnlyFieldsOnInsert');
ga.getXMLAnswer(markReadonly);
}
else {
ga = new GlideAjax('StdChangeUtils');
ga.addParam('sysparm_name', 'ajaxFunction_getReadOnlyFields');
ga.addParam('sysparm_sysId', g_form.getUniqueValue());
ga.addParam('sysparm_tableName', 'change_request');
ga.getXMLAnswer(markReadonly);
}
}
}
function markReadonly(answer){
if(answer){
var parsedAttributeNames = answer.split(',');
for(var i = 0; i < parsedAttributeNames.length; i++){
if(g_form.hasField(parsedAttributeNames[i]))
g_form.setReadOnly(parsedAttributeNames[i], true);
}
}