Hide false/empty checkbox variables in HR AgentWorkspace

Kristin_15
Tera Contributor

Hello,

 

When a catalog item is created by a user in the HR Portal, checkbox values are displayed as false or empty when the variable is not selected. These fields are visible with the value false or empty in both the description field & variable fields on a HR Case in Agent Workspace.

 

I can remove the false variables from the additional tab in the HR Portal, but the false checkbox variables still copy to the HR Case via the description field and variable fields. How can I hide the false/empty checkbox variables on a HR Case in Agent Workspace?

 

In the description field on HR Case – false checkboxes appear

Kristin_15_0-1698848407114.png

 

In Variables section on HR Case – empty checkboxes appear

Kristin_15_1-1698848426361.png

 

 

5 REPLIES 5

abirakundu23
Mega Sage

Hi @Kristin_15 ,

Please create a UI policy for empty/false checkbox fields & there have some option applies on form please inactive that option & check it.

 

JulianLemcke
Mega Sage

I don't think this is - with OOTB functionalties - possible to "hide the falses" from the Description field and you'd need some logic for that - but why would you do that? If the "Description" field is read-only (I think it is looking at your screen) then you know that the requestor has not checked that particular box and you do have proven record of that.

 

Furthermore, to hide the variables (btw nice that you leverage the variable formatter here! I'm not a fan that ServiceNow does not have that OOTB enabled) you could use a catalog ui policy (as mentioned by @abirakundu23 ) and select it as "applies on the target record:

 

JulianLemcke_0-1700063994653.png

Because you don't want to make this field "hidden" on the form, if it is "empty" - in that scenario, the end-user would never see it. 

JamesEcoStratus
Mega Guru

Hello Kristin_15,

 

If you are experiencing visibility issues with false or empty checkbox variables on HR Cases in Agent Workspace. You can use a combination of UI Policies and Client Scripts to address this.

 

Here's a step-by-step guide:

 

Create a UI Policy:

  • Navigate to "System Definition" > "UI Policies."
  • Click on "New" to create a new UI Policy.
  • Fill in the necessary details, such as Name and Table.
  • Under "Advanced," add a condition similar to the following:
    1. !current.checkbox_field_name.nil() && current.checkbox_field_name == false
  • Replace checkbox_field_name with the actual name of your checkbox field. This condition checks if the checkbox field is not empty and has a value of false.

 

Define Actions:

  • After defining the condition, go to the "Actions" related list.
  • Click on "New" to add a new action.
  • Choose "Hide" as the action.
  • Configure the action for the fields you want to hide when the condition is met.

 

Apply UI Policy to Form Layout:

  • Once the UI Policy is created, go to the "Form Layout" of the HR Case.
  • Add the UI Policy to the "UI Policy" related list. This ensures that the policy is applied to the form.

 

Create a Client Script:

  • Navigate to "System Definition" > "Client Scripts."
  • Click on "New" to create a new Client Script.
  • Fill in the necessary details, such as Name and Table.
  • Set the "Type" to "onChange."
  • In the "Script" field, use the following code:
    1. function onChange(control, oldValue, newValue, isLoading) {
    2.   if (!isLoading) {
    3. // Check if the checkbox is unchecked
    4. if (!newValue) {
    5. // Hide the checkbox field
    6. g_form.setDisplay("checkbox_field_name", false);
    7. } else {
    8. // Show the checkbox field
    9.   g_form.setDisplay("checkbox_field_name", true);
    10. }
    11.  }
    12. }

 

 

  1. Replace checkbox_field_name with the actual name of your checkbox field.
  2. Apply Client Script to Form Layout:
    • After creating the Client Script, go to the "Form Layout" of the HR Case.
    • Add the Client Script to the "Client Scripts" related list.

 

These steps should help you hide false or empty checkbox variables on an HR Case in the Agent Workspace. Remember to replace checkbox_field_name with the actual name of your checkbox field in both the UI Policy and Client Script. Additionally, test the solution thoroughly to ensure it meets your requirements.

 

Best of luck with your ServiceNow project.

 

James @Ecostratus

If you found this response helpful, please mark it as "Helpful" or "Correct."

Kristin_15
Tera Contributor

Hello JamesEcoStratus,

Thank you for your response. I tried the UI Policy and Client Script you posted above, but the checkbox fields were still visible in the HR Case. We are collecting the data from the HR Record Producer and then copying and pasting into the Description field on the HR Case in Agent Workspace. Should this be a Business Rule instead of a UI Policy and Client Script?