Create two drop down fields "State" and "City". When state is selected, appropriate cities under that state should be displayed. Ex: States - Telangana, Andhra Pradesh, TamilNadu etc..

d v sumanth1
Tera Contributor

thats it

1 ACCEPTED SOLUTION

Dan Shores
Mega Expert

Deepak's suggestion to use a dependent field is definitely the best option, if you have issues a second option could be a client script using g_form.getValue('field') and using an if statement with g_form.addOption('city', 'option value') or g_form.removeOption('city', 'option value') within. 

 

Below is an example of an onload client script i recently used to remove an option on a specific change type, for some reason dependent values were not working in this case (have used them elsewhere so not sure why this was different).

 

function onLoad() {
    //Type appropriate comment here, and begin script below
    var type = g_form.getValue('type');
    var impact = g_form.getValue('u_moc_level_of_impact');

    if (impact ==  'critical' && type != 'moc_global') {
		g_form.addErrorMessage('Level of impact can no longer be critical on Non-Global MOC records. Impact has been changed to Major on this MOC.');
        g_form.setValue('u_moc_level_of_impact', 'major');
		g_form.removeOption('u_moc_level_of_impact', 'critical');
    } if(type != 'moc_global'){
		g_form.removeOption('u_moc_level_of_impact', 'critical');
		
	}
   
}

Thanks,

 

Dan

View solution in original post

2 REPLIES 2

Deepak Kumar5
Kilo Sage

You can set "State" field in dependent for City. In Choice list, set state list first then for city, add state choices in dependent value.

Refer Incident's category and sub-category fields.

find_real_file.png

find_real_file.png

 

 

Dan Shores
Mega Expert

Deepak's suggestion to use a dependent field is definitely the best option, if you have issues a second option could be a client script using g_form.getValue('field') and using an if statement with g_form.addOption('city', 'option value') or g_form.removeOption('city', 'option value') within. 

 

Below is an example of an onload client script i recently used to remove an option on a specific change type, for some reason dependent values were not working in this case (have used them elsewhere so not sure why this was different).

 

function onLoad() {
    //Type appropriate comment here, and begin script below
    var type = g_form.getValue('type');
    var impact = g_form.getValue('u_moc_level_of_impact');

    if (impact ==  'critical' && type != 'moc_global') {
		g_form.addErrorMessage('Level of impact can no longer be critical on Non-Global MOC records. Impact has been changed to Major on this MOC.');
        g_form.setValue('u_moc_level_of_impact', 'major');
		g_form.removeOption('u_moc_level_of_impact', 'critical');
    } if(type != 'moc_global'){
		g_form.removeOption('u_moc_level_of_impact', 'critical');
		
	}
   
}

Thanks,

 

Dan