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 12:57 AM
Hi,
Thanks for reply but I don't agree that we cannot use control for setting/clearing value. Any thread or documentation for same?
Though I have learned now that control is not accessible in portal so this could be a good reason in my case for not using it in client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2020 01:08 AM
Hi,
Check this thread: https://community.servicenow.com/community?id=community_question&sys_id=69a7acbbdb91a3809540e15b8a96...
Also in doc says that control it's not supported in Service Portal.
If it was helpful, please give positive feedback.
Thanks,
☆ Community Rising Star 22, 23 & 24 ☆

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2020 12:31 AM
Hi,
What is control that you are using here?
you need to mention the field names that you want to clear, like you are doing for u_age.
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 12:43 AM
Hi,
Control object will give you HTML object for that field so that you can change or use it as per your need for example If we wants to change the dynamically field size, length etc in ui page .
You cannot use Control Object to g_form.setValue() and g_form_clearValue().
Please mark reply as Helpful/Correct, if applicable.
Kind Regards,
Hemant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2020 12:57 AM
I don't agree that we cannot use control for setting/clearing value. Any thread or documentation for same?