Hide empty variables on incident records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2022 04:26 PM
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.
Many thanks,
Amy
- Labels:
-
Multiple Versions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2022 04:38 PM
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2022 07:53 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2022 04:00 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2024 04:38 AM
@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