Hide empty variables on incident records

Amy Palaghia
Tera Contributor

Hi,

We've got the incident variable editor displayed on the incident records and I'm wondering if I can only display it if the record was created via a certain record producer.

If this is not possible, then would someone please help me with a script on how to hide that section if variables are empty. The answers that I've seen were about hiding the variables on the RITM table and I'm not sure how to replace that code to fit my requirements.

find_real_file.png

Many thanks,

Amy

5 REPLIES 5

Dan H
Tera Guru

Hi,

If the "Variables" related list is empty on the current record you can hide it by updating the list control of the related list.

find_real_file.png

https://docs.servicenow.com/bundle/paris-platform-administration/page/administer/list-administration...

 

Alternatively,

You can use a onLoad client script to hide the related list.

function onLoad(){

if(specify certain conditions here, or delete this line, for example name of record producer that created this record){

g_form.hideRelatedList('name of the related list');

}

}

 

If this answer has helped or solved your query, please mark it as correct so that others with a similar query can find this article easier

Ankur Bawiskar
Tera Patron
Tera Patron

@Amy Palaghia 

if you wish to hide that entire section for incidents not created from any record producer then do this

1) display business rule on incident table

var gr = new GlideRecord("sc_item_produced_record");
gr.addQuery("task", current.sys_id);
gr.query();
g_scratchpad.fromRecordProducer = gr.hasNext();

2) onLoad client script on incident table

function onLoad(){
  
	if(g_scratchpad.fromRecordProducer.toString() == 'false'){
		g_form.setSectionDisplay('variables', false); // give correct section name
	}
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Amy Palaghia 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar can u pls help me in hiding empty fields in my case form, it is taking all variables from record producer even user have not filled them