How to use this client script on a UI page

Swetha M
Mega Guru

I have an onchange client script for dependency field..(my category should be populated  with class(cmdb_ci's class value) value based on cmdb_ci value )

I need to use this script on my UI page Client script part. I know we cannot use the same syntax there. Any idea on how to proceed?

 


var itComponent = g_form.getValue('u_level_1');
if(newValue != '' && itComponent != ''){
var configValue = g_form.getReference('cmdb_ci');
var className =configValue.sys_class_name;
var choice = g_form.getOption('u_level_1',className).text;
if(choice == ''){
var check = g_form.setValue('u_level_1', g_form.getOption('u_level_1','Unknown').text);
jslog(check);
}
g_form.setValue('u_level_1',choice);
g_form.setReadOnly('u_level_1',true);
}
else{
g_form.setValue('u_level_1','-- None --');
g_form.setReadOnly('u_level_1',true);
}

4 REPLIES 4

Community Alums
Not applicable

Swetha M
Mega Guru

@Ankur Bawiskar  can you please help me on this??

Ankur Bawiskar
Tera Patron
Tera Patron

@Swetha M 

Can you explain your business requirement here?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

my category should be populated  with class(cmdb_ci's class value) value based on cmdb_ci value 
CMDI_CI is my dependent field and when it is populated, the corresponding class of the CI should be populated in my Category field(u_level_1).. I need a client script for my UI page. I have a regular client script.

I have an onchange client script for dependency field..(my category should be populated  with class(cmdb_ci's class value) value based on cmdb_ci value )

I need to use this script on my UI page Client script part. I know we cannot use the same syntax there. Any idea on how to proceed?

 


var itComponent = g_form.getValue('u_level_1');
if(newValue != '' && itComponent != ''){
var configValue = g_form.getReference('cmdb_ci');
var className =configValue.sys_class_name;
var choice = g_form.getOption('u_level_1',className).text;
if(choice == ''){
var check = g_form.setValue('u_level_1', g_form.getOption('u_level_1','Unknown').text);
jslog(check);
}
g_form.setValue('u_level_1',choice);
g_form.setReadOnly('u_level_1',true);
}
else{
g_form.setValue('u_level_1','-- None --');
g_form.setReadOnly('u_level_1',true);
}

 

 

Help with code would be great. Thanks in advance.