If subcategory is email or antivirus then service field must be hidden

Shubham_verma
Tera Contributor

If subcategory is email or antivirus then service field must be hidden on incident form.How to achieve this using client script?

1 ACCEPTED SOLUTION

@Shubham_verma  write on change client script on subcategory field and use the below code snippet.

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (newValue === '') {
        return;
    }
    
    var subcategory = g_form.getValue('subcategory');
    
    if (subcategory == 'email' || subcategory == 'antivirus') {
        g_form.setDisplay('business_service', false);
    } else {
        g_form.setDisplay('business_service', true);
    }
}

 

 



View solution in original post

6 REPLIES 6

Veer
Tera Guru

Hello @Shubham_verma,

To achieve this, you can use a UI Policy. Here are the steps:

  1. Create a UI policy on the table where you want this logic to be applied (I believe it's the Incident table).
  2. Provide a short description like "Hide Service when Subcategory is Email or Antivirus".
  3. In the condition field, select "Subcategory is Email" or "Subcategory is Antivirus".
  4. Save the UI policy form. You should see a related list.
  5. In the UI policy action related list, click "New" and select "Service" as the field.
  6. Set the visible to "False".
  7. Make sure to check "Reverse if false" and "OnLoad" checkboxes while creating the UI Policy.

Hope this helps.

I want to achieve this using client script.

@Shubham_verma  write on change client script on subcategory field and use the below code snippet.

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (newValue === '') {
        return;
    }
    
    var subcategory = g_form.getValue('subcategory');
    
    if (subcategory == 'email' || subcategory == 'antivirus') {
        g_form.setDisplay('business_service', false);
    } else {
        g_form.setDisplay('business_service', true);
    }
}

 

 



It worked.Thanks