How to set a variable with default value based on the another variable in the catalog form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2018 07:18 AM
I am trying to auto populate 3 single line text variables(RAM,CPU,Storage) with default values based on another variable "Server type"(type-choice) on the catalog form.Client script is not working for it.Don't know how to implement through macros.
Please let me know if you have any further questions.
Thank you for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2018 10:03 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setValue('CPU',"");
g_form.setValue('RAM',"");
g_form.setValue('storage',"");
}
else if(newValue=='Small VM'){
g_from.setValue('RAM',"4");
g_from.setValue('CPU',"2");
g_from.setValue('storage',"150");
}
else if(newValue=='Medium VM')
{
g_from.setValue('RAM',"8");
g_from.setValue('CPU',"4");
g_from.setValue('storage',"300");
}
else if(newValue=='Large VM'){
g_from.setValue('RAM',"16");
g_from.setValue('CPU',"8");
g_from.setValue('storage',"600");
}
else if(newValue=='X-Large VM'){
g_from.setValue('RAM',"32");
g_from.setValue('CPU',"16");
g_from.setValue('storage',"800");
}
//Type appropriate comment here, and begin script below
return;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2018 10:34 AM
did you make sure that you are setting database names of fields but not labels/display value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2018 10:43 AM
Yes,I am sure.Those all are database values only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2018 11:50 AM
Try in this way! if this works
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setValue('CPU',"");
g_form.setValue('RAM',"");
g_form.setValue('storage',"");
}
var servertypevalue = g_form.getValue('Server type'); // OR give whatever database name it is
if(servertypevalue =='Small VM'){
g_from.setValue('RAM',"4");
g_from.setValue('CPU',"2");
g_from.setValue('storage',"150");
}
else if(servertypevalue =='Medium VM')
{
g_from.setValue('RAM',"8");
g_from.setValue('CPU',"4");
g_from.setValue('storage',"300");
}
else if(servertypevalue =='Large VM'){
g_from.setValue('RAM',"16");
g_from.setValue('CPU',"8");
g_from.setValue('storage',"600");
}
else if(servertypevalue =='X-Large VM'){
g_from.setValue('RAM',"32");
g_from.setValue('CPU',"16");
g_from.setValue('storage',"800");
}
//Type appropriate comment here, and begin script below
return;
}