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

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