Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

client script if I select the state as In progress means I want to make field 1 visible in incident form

Dhivya10
Tera Contributor

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..

1 ACCEPTED SOLUTION

Voona Rohila
Tera Patron

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
5x ServiceNow MVP

View solution in original post

5 REPLIES 5

Voona Rohila
Tera Patron

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
5x ServiceNow MVP