Unable to set/clear value of a variable with "onChange" client script - "control" object - within a multi row variableset
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2020 12:18 AM
Hi,
I am unable to set/clear value of a variable with "onChange" client script - "control" object - within a multi row variableset. Is it a known issue Or anything wrong with my code or PDI?
See below code and attached screenshot.
g_form.setValue('u_age',''); // working
g_form.setValue(control,''); // not working
g_form.clearValue(control); // not working
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2020 01:09 AM
Hello Faisal,
As hemant mentioned control returns the html widget of the variable. Here is the reference for you.
So use the field name which you want to clear inside your client script.
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2020 01:10 AM
If you do not want to hardcode a variable name, then may be you can try this
g_form.getFieldNames();
Try this out.
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2020 01:16 AM
Avoid using control object to set value or clear value.
Use:
g_form.setValue('actual_fieldName','Value');
g_form.clearValue('actual_fieldName');
Please mark reply as Helpful/Correct.
Regards,
Hemant