Ui action on one table should visible with respect to other table check box

jobin1
Tera Expert

Hi All

we have one ui action called View HTML  on  u_email_client table now this ui action button should be visible only when u_company_config_intg_ table  u_html_email_content checked (true) for those companies only this ui action should be available how this can be done?  

jobin1_0-1700667710523.png

 

2 REPLIES 2

Clara Lemos
Mega Sage
Mega Sage

Hi @jobin1,

 

Do you have a "company" field on the "u_email_client" table? ( a reference field to the Company table)

If yes, you can do the following

Create a new Script Include (navigate to System Definition > Script Includes)

Screenshot 2023-11-22 at 19.35.06.png

 You can try something like this for the script: 

 

var uiActionUtils = Class.create();
uiActionUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    type: 'uiActionUtils',
		hideViewHtml: function(){
		var checkbox = new GlideRecord('u_company_config_intg');// you'll need to do a Glide Record on your table 
		checkbox.addQuery('company',current.company); // look for the record that has the company selected in the u_email_client table, you should add instead of 'company; the name of the field in the ;u_company_config_intg; table and current.{the name of the field in the u_email_client table.}
		checkbox.query(); // query
		while(checkbox.next()){ // if you only have one you can use an if and if could have multiple you can use a while
			if(checkbox.u_html_email_content==true){ //if the checkbox is true
				return true; // return true ( will display the UI Action)
			}
		}
		return false;// in any other scenario will not display the ui action
	}
});

 

Now, in you UI Action you'll need the script to your condition:

 

Screenshot 2023-11-22 at 19.36.27.png

 If that helps please mark my answer as correct / helpful!
And if further help is needed please let me know

Cheers

 

 

HI Clara
I have only sys_domain in u_email_client table which will be same in u_company_config_intg   

u_company  filed i tried the below script but not working.
 
   
var BPO_CSS_Di_Intergation_Company_validation = Class.create();
BPO_CSS_Di_Intergation_Company_validation.prototype = {
    initialize: function() {
    },
    hideViewHtml: function() {
        gs.log("cmpyval1");
        var checkbox = new GlideRecord('u_company_config_intg');

        checkbox.addQuery('u_company', current.sys_domain);
        checkbox.addQuery('u_active', true);
        checkbox.query();
        while (checkbox.next()) {
            gs.log("cmpyval2");
            if (checkbox.u_html_email_content == true) {
                gs.log("cmpyval3");
                return true;
            }
        }
        return false;
    }
};

BPO_CSS_Di_Intergation_Company_validation.prototype.type = 'BPO_CSS_Di_Intergation_Company_validation';


jobin1_1-1700725020464.png

 

    ui action condition
Javascript: new globaluiActionUtils().hideViewHtml()







jobin1_0-1700723472245.png