hide empty variable in variable editor on record producer

Deepanshi1
Mega Guru

hi i created a record producer and i want to show all variable value in my case form too, so i added variable editor. now my case form is also showing empty variable also, how can i remove empty field. these fields are mandatory, but it is working on ui policy i created on record producer. i want only that variables that user have filled in record producer from portal.

1 ACCEPTED SOLUTION

ChrisBurks
Giga Sage

Catalog Client Scripts and Catalog UI Policies have attributes that can be checked to apply it on the item, target task or target record or all. Use the one that fits your needs to hide the appropriate variable(s) and check the box(es) where appropriate.

 

Catalog Client Script

catalog_client_script.png

 

 

Catalog UI Policy
catalog_ui_policy.png

View solution in original post

2 REPLIES 2

shloke04
Kilo Patron

Hi @Deepanshi1 ,

Follow the steps below to achieve this:

1. Write a display BR on your Case table and use the script shared below:

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

	// Add your code here
	var arr = [];
	var gr = new GlideRecord('question_answer');
	gr.addQuery('table_name',current.getTableName());
	gr.addQuery('table_sys_id',current.sys_id);
	gr.addEncodedQuery('valueISEMPTY');
	gr.query();
	while(gr.next()){
		arr.push(gr.question.name.toString());
	}
	g_scratchpad.hideVariables = arr.toString();

})(current, previous);

 

2. Now write an On Load Client Script on Case table and use the script shared below:

function onLoad() {
   //Type appropriate comment here, and begin script below
   var getVariables = g_scratchpad.hideVariables.split(',');
   for(var i=0 ; i<getVariables.length;i++){
	g_form.setDisplay(variables.getVariables[i],false);
   }
}
Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

ChrisBurks
Giga Sage

Catalog Client Scripts and Catalog UI Policies have attributes that can be checked to apply it on the item, target task or target record or all. Use the one that fits your needs to hide the appropriate variable(s) and check the box(es) where appropriate.

 

Catalog Client Script

catalog_client_script.png

 

 

Catalog UI Policy
catalog_ui_policy.png