- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2022 12:03 AM
I created 4 fields as field1,field2,field3,field4 in incident form. If I select the In progress state means I want field1 should be visible and mandatory rest of field2,field3,field4 should not visible in incident form..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2022 12:14 AM
Hi Dhivya
Did you try anything so far and got stuck? it's easy and doesnt require any script to do with UI Policies.
try this
if(newValue=="in progress state backend value") // please replace work in progress choice backend value
{
g_form.setDisplay('field1',true);
g_form.setMandatory('field1',true)
g_form.setDisplay('field2',false);
g_form.setDisplay('field3',false);
g_form.setDisplay('field4',false);
}
else
{
//modify below statements accordingly if you want to show the fieldss if state is not inprogress.
g_form.setMandatory('field1',false);
g_form.setDisplay('field2',false);
g_form.setDisplay('field2',true);
g_form.setDisplay('field3',true);
g_form.setDisplay('field4',true);
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2022 12:06 AM
Hi you can use UI Policy
Condition: state is In progress
Field 1 : visible true , Mandatory: true
field 2,3,4: visible false
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2022 12:10 AM
how to make it in client scripts..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2022 12:16 AM
Hi Avoid Client scripts if you can achieve it through UI Policy. Always follow best practices .
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2022 12:11 AM
Hello ,
You can write a on change client script for this on state field
script:
if(newValue=="in progress state backend value") // please replace work in progress choice backend value
{
g_form.setMandatory('field1',true)
g_form.setVisible('field2',false);
g_form.setVisible('field3',false);
g_form.setVisible('field4',false);
}
else
{
g_form.setMandatory('field1',false)
g_form.setVisible('field2',true);
g_form.setVisible('field3',true);
g_form.setVisible('field4',true);
}
OR you can congigure a Ui ploicy to do the same.To know how to create Ui policy follow below link
Please accept the solution and close the thread if this helps you
thanks