We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to keep custom table field value in sync with variable value?

Valqe
Tera Expert

Hi all,

Need your help and I welcome your comments.

I have created custom table and I have introduced variables in the form view of this table (used UI Formatter feature)

Requirement: I need to update custom table field value when variable value changes.

I understand I (probably) need to create a BR, but not sure which table to query for this BR.

------------

Pasting visualization of my question below.

1. Whenever "Canned response" VARIABLE field changes, I need to 

2. Reflect the change in "Canned response" FIELD in my custom table.

 

I appreciate your comments 🙂

find_real_file.png

1 ACCEPTED SOLUTION

Not applicable

The way I addressed this requirement was similar to:

1. Navigate to 'Record Producer' record which you used to populate custom table variables.

2. Create new "Catalog Client Script" of a "onChange" type , which applies only on Target Record,

3. Select Variable name: i.e. Canned Response

4. Apply the following script:

g_form.setValue('canned_response', g_form.getValue('variables.canned_response'));

 

 

View solution in original post

3 REPLIES 3

Jan Cernocky
Tera Guru

Hi Valque,

this should be accessible the following way:

current.canned_response = current.variables.canned_response

(depending on your field names)

Thank you Jan,

Question: Where would you use this script line? I am not sure if it will work on 'On Change' of a 'Client Script' and if BR I am not sure on which table to use it.

I appreciate your response.

Not applicable

The way I addressed this requirement was similar to:

1. Navigate to 'Record Producer' record which you used to populate custom table variables.

2. Create new "Catalog Client Script" of a "onChange" type , which applies only on Target Record,

3. Select Variable name: i.e. Canned Response

4. Apply the following script:

g_form.setValue('canned_response', g_form.getValue('variables.canned_response'));