hide/show subcategory

Renu4
Tera Contributor

Hello Everyone,

 

I have worked on a client script where if i select category then subcaegory field is populated.

However when the incident is saved the subcategory field gets hidden again.

How should i keep it on the screen after saving/submit.

For more info i have attached the screen shot and the code of my script.

 

aftersubmit.PNGbeforesubmit.PNG

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        g_form.setDisplay('subcategory', false);
        return;
    }
    var val = g_form.getValue('category');
    if (val == "incident_outage" || val == "inquiry") {
        g_form.setDisplay('subcategory', true);
    } else {
        g_form.setDisplay('subcategory', false);
    }


}

 

The image 2 shows the subcategory before saving however once this incident gets saved then subcategory is hidden as in image 1.

Please guide.

 

Thanks in Advance,

Renu.

6 REPLIES 6

AnveshKumar M
Tera Sage
Tera Sage

Hi @Renu4 ,

 

What is the dictionary configuration of the sub category field, is it hidden by default?

If it is hidden by default, try writing an onLoad client script which should check if the sub category field contains a value or not, if value is present setDisplay to true otherwise set it to false.

OR

You can also use a UI Policy to get this.

 

Example onLoad client script:

 

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

	if(sub_cat){
		g_form.setDisplay('sub_category', true);
	}
}

AnveshKumarM_0-1681106088106.png

 

You can further modify this onLoad client script to include other conditions too.

Thanks,

Anvesh

Thanks,
Anvesh

This works for me but what about when the ticket is submitted?the field disappears on the ticket saving.

Hello @Renu4 
Did you checked may be there are some other client script written for it onSubmit or may be a ui policy is already there so please check if there are any such existing script written

 

Please mark my answer correct and helpful if it helps you

@Renu4 ,

There must be some client scripts or UI Action which is hiding this field, check for that.

 

Thanks,

Anvesh

Thanks,
Anvesh