incident variable editor (formatter) if blank then hide the section

Debasis Pati
Tera Guru

I have added the incident variable editor(formatter ) in one section of my incident form for the sow view.

Now if the incident is created from record producer then the variables are showing in the variables section that is fine.

But if the record is created normally by clicking on new the record doesn't have any variables but the section variables is shown which is not required.
I want if there are no variables present in the Variables section it should not be visible how i can achieve this?

DebasisPati_0-1753245305135.png

 


@Ankur Bawiskar  any suggestions?

Regards,
Debasis

7 REPLIES 7

PrashanthR95946
ServiceNow Employee
ServiceNow Employee

@Debasis Pati  while creating an incident from record producer update the contact type as self-service or portal.

 

write a client script/ ui policy if contact type is self-service or portal show the variable section.

Shruti
Mega Sage
Mega Sage

Hi,

Create a UI policy on incident table

Display variables section only when channel is self-service

Shruti_0-1753247454396.pngShruti_1-1753247463483.png

 

This will work but is there any other way to identify if it is created from record producer or not because from backend also we can create a incident record putting the channel as self-service right in that case it will fail.

Regards,

Debasis

Hi,

Another way is to use Display Business rule and client script

Display Business rule

(function executeRule(current, previous /*null when async*/ ) {
    g_scratchpad.showVariables = false;

    var grRec = new GlideRecord('sc_item_produced_record');
    grRec.addEncodedQuery('task=' + current.getUniqueValue() + '^task.sys_class_name=incident');
    grRec.query();

    if (grRec.next()) {
        g_scratchpad.showVariables = true;
    }

})(current, previous);

OnLoad Client Script

function onLoad() {
   //Type appropriate comment here, and begin script below
   if(g_scratchpad.showVariables){
	g_form.setSectionDisplay('variables',true);
   }
   else{
	g_form.setSectionDisplay('variables',false);
   }

}