fName-Value field types do not return in g_form.getEditableFields()

Vin Fredrick
Tera Expert

Hi Folks, 

I have a few Name-Value field types on a form - and I'm using an OnLoad Client Script to pull all editable fields - but Name-Value fields do not show-up in the array. 

 

The code that I'm using in the OnLoad Client-Script is: 

 

    var fields = g_form.getEditableFields();
    for (var x = 0; x < fields.length; x++) {
        g_form.setReadOnly(fields[x], true);
    }
 
I get all the fields - but none of the Name-Value pair fields. Its not a major problem - but just wanted to know the reason behind this. 
1 ACCEPTED SOLUTION

Thanks for the update - but it didn't work. Upon further research - I found this KB from ServiceNow 

 KB0827178 - https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0827178 

 

Look's like there's no solution for it at the moment: 

"After carefully considering the severity and frequency of this problem and the risk of attempting a fix, it has been decided to not address this issue in any current or future releases. We do not make these decisions lightly, and we apologize for any inconvenience." 

 

However, one strange thing is - the same code g_form.setReadOnly('u_namevaluePairFieldName',true) works fine in an UI Action script

View solution in original post

3 REPLIES 3

Dnyaneshwaree
Mega Sage

Hello @Vin Fredrick ,

Below code is updated version of your script:

var fields = g_form.getEditableFields();

// List of Name-Value pair fields (replace 'name_value_field1', 'name_value_field2', etc. with actual field names)
var nameValueFields = ['name_value_field1', 'name_value_field2'];

// Combine the arrays
fields = fields.concat(nameValueFields);

for (var x = 0; x < fields.length; x++) {
    g_form.setReadOnly(fields[x], true);
}

 

Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru

Thanks for the update - but it didn't work. Upon further research - I found this KB from ServiceNow 

 KB0827178 - https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0827178 

 

Look's like there's no solution for it at the moment: 

"After carefully considering the severity and frequency of this problem and the risk of attempting a fix, it has been decided to not address this issue in any current or future releases. We do not make these decisions lightly, and we apologize for any inconvenience." 

 

However, one strange thing is - the same code g_form.setReadOnly('u_namevaluePairFieldName',true) works fine in an UI Action script

Mohan raj
Mega Sage

Hi @Vin Fredrick,

 

Name of the fields (backend name of the value) will get by using the getEditableFields() method. Value are stored in database. so to pull the value need to right Server side script to pull the value of the field.

 

If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.