OnChange client script on dot walked field

sanvi
Tera Expert

Hi All,

 

I have a table called 'Allegation Outcomes' in which there is a dot walked field called Allegation type.

sanvi_1-1747203699596.png

An onchange client script needs to be configured on this field and on change of this field options have to be added and removed in the outcome field.

Issue: unable to configure the onchange 'Field name' for dot walked field.

 

Can anybody suggest an alternative or any other solution to achieve the results?

phgdet
Mega Sage

Hi @sanvi,

  1. Create an onChange Client script with any other field
  2. Open the Client script list view, filter on that client script
  3. Add column “Field name”
  4. Replace the Field name value with the dot walk field like: “table.field_name”

Note: dot walked field needs to be on the form

Original answer is provided by Mate Levai from this QA: https://www.servicenow.com/community/itsm-forum/onchange-client-script-for-changing-dot-walk-field/t...

Hi @phgdet ,

I tried the above steps. but once i update the field name from list view and once i update the script and save it the field name becomes empty.

 

hi @sanvi,

So that you need to update <field name> on the list once again after modify your code.
Or you can run a background script every time you modified your code.

var current = new GlideRecord("sys_script_client");
if (current.get("<your_client_script_id>")){
	current.setValue("field", "table.field_name"); //type your dot walked field here
	current.update();
}

Hi @phgdet ,

I feel this as risk. What if by miss the code stops working in PROD??

Is there any other way that this can be achieved?