Use g_form.getValue in UI script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2022 01:05 AM
Can I use g_form.getValue() in UI script?
I am looking for way to control catalog item variables in UI script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2022 01:21 AM
Hi @Jaeik Lee ,
Yes, you can use the g_form.getValue()
method in a UI script to get the value of a field on a form.
To control catalog item variables in a UI script, you can use the g_form.setValue()
method to set the value of a variable.
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2022 09:39 PM
Thank you for Help!!
I tried to call UI script in Client Script, but it failed.
this is my script :
UI script
checkDate.checkStart = function(start, end, today){
var start_date = new Date(g_form.getValue(start));
var end_date = new Date(g_form.getValue(end));
if(start_date < today){
g_form.addErrorMessage('test');
g_form.clearValue(start);
return;
}
if(end_date < start_date){
g_form.addErrorMessage('test');
g_form.clearValue(end);
return;
}
}
Client Script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
checkDate.checkStart('d_start', 'd_end', new Date());
}