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.

Hide sections in form incident

Shir Sharvit
Tera Contributor

Hi,

I want that under certain conditions:
that when the location of the caller_id is Londrina ADM
And when the company is Adama Brasil S.A.

So I want to hide the form section from the form.

ShirSharvit_0-1719389468860.png

 

Thanks, Shir

10 REPLIES 10

Amit Pandey
Kilo Sage

Hi @Shir Sharvit 

 

You can use UI policies to hide sections. Pls refer to this post-

 

https://www.servicenow.com/community/developer-articles/how-to-using-ui-policies-to-hide-form-sectio...

 

Regards,

Amit

Pratima Kalamka
Kilo Sage

Hello @Shir Sharvit 

Use the UI polices for the hide section :

condition: caller location Londrina ADM

                  company is Adama Brasil S.A.

Please refer below link it will help you:

https://www.servicenow.com/community/developer-articles/how-to-using-ui-policies-to-hide-form-sectio... 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0696583 

https://www.servicenow.com/community/developer-forum/how-to-hide-form-section-based-on-condition/m-p... 

 

 

If my answer is helpful please mark it as helpful or correct!!

 

Pratima.k

swathisarang98
Giga Sage

Hi @Shir Sharvit ,

 

You can do this through UI policy or client script,

 

I have tried onchange client script please check the code below,

swathisarang98_0-1719392551581.pngswathisarang98_1-1719392569047.png

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    
    var caller = g_form.getReference('caller_id', getcallerDetail);

    function getcallerDetail(caller) {
		if(caller.location == '3e94ed7437d0200044e0bfc8bcbe5d9b' && caller.company == '227cdfb03710200044e0bfc8bcbe5d6b') //here add the location sysid and company sysid 
{
			g_form.setSectionDisplay('notes',false);
			//alert('inside');
			//alert(g_form.getSectionNames()); //to get the section names

		}
		else{
			g_form.setSectionDisplay('notes',true);
		}

    }

}

 

 

Note: If you want to use it when page loads then create one more Onload client script add the same code it will work .

 

Please check and Mark Helpful and Correct if it really helps you.

Regards,

Swathi Sarang