Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Collapse the variables on the incident form on a specific view

riskay123
Mega Guru

I have two questions that I was hoping someone could assist me with please. 

 

1. How can I make the section be collapsed by default on a specific view?

2. How can I make it not appear as a tab but directly on the form?

 

I have a requirement provide some fulfillers the ability to view the Incident form where the Variables section would be collapsed by default.

 

I have created a new view for the incident form, and I have created a section called "Variables" and added the Variable Editor to this section on the form. This does now give the user to collapse or expand the section as they need but I would like it to be collapsed by default when the page loads if this view is selected.

 

I have tried adding this client script it does not seem to make any difference.  How can I go about allowing this view to have this section collapses by default when it loads.

 

function onLoad() {

    // Specify the view name where you want to collapse the Variable Editor

    var targetView = 'CV2'; // Replace 'your_view_name' with the actual view name

 

    // Check if the current view matches the target view

    if (g_form.getViewName() === targetView) {

        // Wait for the Variable Editor to load

        setTimeout(function() {

            // Collapse the Variables section

            g_form.setSectionDisplay('variables', false);

        }, 1000); // Adjust the delay as needed

    }

}

 

My second question relates to the additional section appearing in a tab. When I add in the additional tabs like "Notes" and "Related Records" which I do want to appear in tabs on the form. But it moves the Variables section from the form to a tab. I would like the "Variables" section to appear on the main form and not on a tab.

Tab view.jpg

 

I did a quick google it indicated that on the Configure > Form Layout form there should be a tick box that we can tick or untick to make this section, so it does not appear in the tab. I can't see this tick box on the form in my PDI. There does not appear to be a Context Menu option on that form to see if I can add this tick box option to the form.

 

How do I ensure that this section does not appear on the Incident form?

 

Thank you 

0 REPLIES 0