Hide filed based on assigned to group

Mannam Praveen
Tera Expert

I want show particular field on the form only when assigned to is part of Service Desk Group and only for opened by user. how to acheive this..?

2 ACCEPTED SOLUTIONS

Yes the script is in business rule.

View solution in original post

AnveshKumar M
Tera Sage
Tera Sage

Hi @Mannam Praveen  ,

You need to write some onload client script and display business rule like the one below.

 

onLoad Client Script:

 

function onLoad() {

	if(g_scratchpad.display_particular_field == true){
		g_form.setVisible('your_field_name', true); //chnage it to your field name
	}else{
		g_form.setVisible('your_field_name', false); //chnage it to your field name
	}
   
}

 

AnveshKumarM_2-1695797572500.png

 

Display Business Rule:

 

(function executeRule(current, previous /*null when async*/) {

	var memGr = new GlideRecord('sys_user_grmember');
	memGr.addQuery('user', current.assigned_to);
	memGr.addQuery('group', 'd625dccec0a8016700a222a0f7900d06');
	memGr.query();

	if(memGr.next()){
		g_scratchpad.display_particular_field = true;
	}else if(user == current.opened_by){
		g_scratchpad.display_particular_field = true;
	}else{
		g_scratchpad.display_particular_field = false;
	}

})(current, previous);

 

AnveshKumarM_0-1695797524684.png

 

AnveshKumarM_1-1695797535193.png

 

Please mark my answer helpful and accept as solution if it helped you 👍✔️

 

Thanks,
Anvesh

View solution in original post

5 REPLIES 5

Anand Kumar P
Giga Patron
Giga Patron

Hi @Mannam Praveen  
Use below script,

var assignedTo = current.assigned_to;
var gr = new GlideRecord('sys_user_grmember'); 
gr.addQuery('user', assignedTo); 
gr.addQuery('group', 'IT Service Desk'); 
gr.query();

if (gr.next()) {
    var openedBy = current.opened_by;
    var currentUser = gs.getUserID();

    if (openedBy == currentUser) {
        current.setDisplay('field_to_show', true); 
    }
}

Thanks,

Anand 

We need write this script in the business rule right

Yes the script is in business rule.

Hi @Mannam Praveen  ,

Please mark it as helpful.

Thanks,

Anand