making field visible with respect to other table condition

jobin1
Tera Expert

Hi All,

in u_company_config_intg table if the below condition is satisfied then only the u_html_message field should be visible in u_email_client table how this can be achieved? any simple way?


condition
var cmpcon = new GlideRecord('u_company_config_intg');
cmpcon.addEncodedQuery('u_active=True^u_di_email_ingestion=true^u_html_email_content=true');
cmpcon.query();

3 REPLIES 3

Ratnakar7
Mega Sage
Mega Sage

Hi @jobin1 ,

 

To make a field visible in one table based on a condition in another table, you can use UI Policies / Client Scripts.

Configure the conditions for when the UI Policy should be applied. In your case, it should be applied when the condition you mentioned is satisfied. You can use a Script condition for this.

Here's an example of how to write the script condition:

// Check if the condition in u_company_config_intg is satisfied
var cmpcon = new GlideRecord('u_company_config_intg');
cmpcon.addEncodedQuery('u_active=true^u_di_email_ingestion=true^u_html_email_content=true');
cmpcon.query();

// Apply the UI Policy if the condition is satisfied
if (cmpcon.next()) {
    true; // Apply the UI Policy
} else {
    false; // Do not apply the UI Policy
}

 

Thanks,

Ratnakar

the script you mentioned is to validate in ui policy run script (execute if true) session right? how glide record can be used here?

Amit Gujarathi
Giga Sage
Giga Sage

HI @jobin1 ,
I trust you are doing great.

Here's a step-by-step guide:

  1. Create a UI Policy:

    • Navigate to System UI > UI Policies.
    • Click on New to create a new UI Policy.
    • Fill in the necessary details:
      • Name: A descriptive name for the policy.
      • Table: u_email_client.
      • Order: Order in which the policy should be executed.
      • Conditions: Leave this blank for now. We'll add a script-based condition.
      • Short description: A brief description of the policy.
  2. Add UI Policy Action:

    • Once the UI Policy is created, under the UI Policy Actions related list, click on New.
    • Fill in the details:
      • Field: u_html_message.
      • Visible: True.
      • Mandatory, Read only: As per your requirements.
  3. Script Condition:

    • Go back to the UI Policy record.
    • In the Advanced tab, check the Script checkbox.
    • Add the following script in the Run scripts field:

 

var cmpcon = new GlideRecord('u_company_config_intg');
cmpcon.addEncodedQuery('u_active=True^u_di_email_ingestion=true^u_html_email_content=true');
cmpcon.query();
return cmpcon.hasNext(); // Returns true if the conditions are met, making the field visible.

 


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi