making a field visible

gayatri38
Giga Guru

I have a custom table called "file_route" which has data direction field and a newly created field called security exception. I also have a other custom table called "domain" which has 2 fields which is a checked true/false fields called personal info, health info. Here I want to display security exception when data direction in file_route table is 'inbound' and either personal info or health info is checked.

3 REPLIES 3

Rajesh Chopade1
Mega Sage

Hi

 

To achieve this, you will need to create a business rule or a script to check the conditions and display the security exception based on the criteria. 

 

I hope my answer helps you to resolve your issue, if yes mark my answer helpful and correct.

 

thank you

rajesh chopade

gayatri38
Giga Guru

First i have make the security exception field as visibility false and then in a business rule this is the code i have tried but it didn't work - 

if(data_direction == 'inbound'){
alert("hello");
var ddgr = new GlideRecord('x_data_domain');
//if(ddgr.get('sys_id', current.getValue('data_domain_name'))){
if(ddgr.get(current.data_domain_name)){
var piicheck = ddgr.getValue('personal_info');
var phicheck = ddgr.getValue('health_info');

//alert("world");
if(piicheck == true || phicheck == true){
g_form.setVisible('security_exception', true);
}
else
g_form.setVisible('security_exception', false);
}
}

 

Hi

 

please check following script and conditions for your business rule once:

 

Navigate to: System Definition > Business Rules.

Click New to create a new business rule.

Fill out the form:

  • Name: Display Security Exception
  • Table: file_route
  • When: Before
  • Insert: true
  • Update: true
  • Filter Conditions:
    • data_direction is inbound

Advanced: Check the Advanced checkbox to allow for scripting.

 

(function executeRule(current, previous /*null when async*/) {
    // Ensure we are processing a valid file_route record with 'inbound' data direction
    if (current.data_direction == 'inbound') {
        
        // Fetch related domain record
        var domainGr = new GlideRecord('domain');
        
        // If there's a relation between file_route and domain, you need to query based on that relationship
        // Assuming there's a field `domain` in file_route table which references domain table
        domainGr.get(current.domain);

        // Check the conditions for personal info or health info
        if (domainGr.personal_info == true || domainGr.health_info == true) {
            current.security_exception = 'Some Security Exception Message'; // Or you can set a specific value
           g_form.setVisible('your_field_name',true);
        } else {
            current.security_exception = ''; // Clear the security exception if conditions are not met
           g_form.setVisible('your_field_name',false);
        }
    } else {
        current.security_exception = ''; // Clear the security exception if conditions are not met
g_form.setVisible('your_field_name',false);
    }
    
})(current, previous);

 

 

I hope my answer helps you to resolve your issue, if yes mark my answer helpful and correct.

 

thank you

rajesh chopade