Is Dot-Walking Supported in g_form.setReadOnly() in OOTB Client Script?

Mark Wood
Tera Contributor

Hello Team,

Below is an out-of-the-box (OOTB) client script. While reviewing it, I noticed a potential issue.

The client script uses dot-walking on a reference field to make it read-only. Is this the correct approach, or is this a ServiceNow bug? Based on my experience, the syntax looks incorrect to me, as we cannot use dot-walking in the g_form.setReadOnly() method.Could someone please guide me or share their inputs on this?

thank you.

 

Client Script name:LockGoal.strategyFieldAndHideOldGoal

Table:pm_project

 

function onLoad() {
//Type appropriate comment here, and begin script below
g_form.setReadOnly('primary_goal.strategy', true);
 
if (g_scratchpad.hasAtleastOneGoalOrStrategy) {
g_form.setVisible('goals', false);
g_form.setVisible('strategic_objectives', false);
g_form.hideRelatedList('goal');
}

}

 

1 ACCEPTED SOLUTION

Mohammed8
Giga Sage

Hi @Mark Wood 

 

I tested it and g_form.setReadOnly()  makes dot walking on reference field read-only

 

Before script my incident form:

 

Mohammed8_0-1768898553031.png

script used :

 

Mohammed8_1-1768898592615.png

 

Validation ->After on load script :

 

Mohammed8_2-1768898621457.png

If you find the answer helpful please mark the solution accepted/helpful

 

Regards,

Mohammed Zakir

View solution in original post

1 REPLY 1

Mohammed8
Giga Sage

Hi @Mark Wood 

 

I tested it and g_form.setReadOnly()  makes dot walking on reference field read-only

 

Before script my incident form:

 

Mohammed8_0-1768898553031.png

script used :

 

Mohammed8_1-1768898592615.png

 

Validation ->After on load script :

 

Mohammed8_2-1768898621457.png

If you find the answer helpful please mark the solution accepted/helpful

 

Regards,

Mohammed Zakir