want to make some on hold choices visible for particular category

Rahul Raja Sami
Tera Guru

Hi I have added new choices for On Hold Reason 
1. awaiting delivery
2. awaiting payment

3. awaiting contractor 
and I want them to be visible only when the category is facilities and should be hidden for other categories.

Thanks.

1 ACCEPTED SOLUTION

I was able to achieve this on my PDI for both scenarios.

 

1. Wrote down a onChange client script on Category field & put following code into it

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (newValue === '') {
        return;
    }
    if (isLoading && oldValue != 'inquiry') { ///update with backend value of Facilities choice here
        g_form.removeOption('hold_reason', '1'); //update with backend value of choices which you don't want to see on other categories
        g_form.removeOption('hold_reason', '5');
        return;
    }

    if (newValue === 'inquiry') { //update with backend value of Facilities choice here
        g_form.addOption('hold_reason', '1', 'Awaiting Caller'); //update the backend & front-end labels here which you only want to see in facilities category
        g_form.addOption('hold_reason', '5', 'Awaiting Change');
        return;
    }

    g_form.removeOption('hold_reason', '1');
    g_form.removeOption('hold_reason', '5');

}

 

2. Do make sure you update the backend values & front-end values of the choices.

 

3. In my scenario, I am hiding choices on all other categories apart from 'Inquiry' category. It should work.

 

3.1 Hide on all other categories.png

 

3.2 Show only on Inquiry.png

 

Do mark this response as CORRECT / HELPFUL as it will help others & will motivate me as well to write more.

View solution in original post

12 REPLIES 12

H S B
Giga Guru

Assuming you are talking about the 'On Hold Reason' & 'Category' fields on Incident table & you have already added the Choices to 'On Hold Reason' dictionary, you can write down a onLoad client script on Incident table while refering to following code -

 

var cat = g_form.getValue('category');

 

if(cat!='facilities') //make sure to use the backend value of facilities choice, not the label only

{

g_form.removeOption('hold_reason','awaiting_delivery'); //make sure to use backend values of onHoldReason choices as well here

g_form.removeOption('hold_reason','awaiting_payment');

g_form.removeOption('hold_reason','awaiting_delivery');

}

 

Refer to below article as well for understanding how removeOption function works. This is assuming you are trying to hide only on onLoad. If it is onChange of Category, Refer to Timi's code.

 

Do mark this as HELPFUL / CORRECT appropriately.

Not working HSB

Do you want this to work onLoad of your form or whenever you change the Category to a particular value? If you clear the scenario, I can build it on my own PDI & share exact script. 🙂

its like both