can we make a field mandatory in one view ?

RudhraKAM
Tera Guru

Is it possible to make a field mandatory only in one view ?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Kam,

Good approach would be to create a client script which is onload and specify the view name

so when onload client script runs and if it is that view then only field will be made as mandatory

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Ct111
Tera Sage

Hi,

Try something like this

 


function onLoad() {
var objView = document.getElementById('sysparm_view');
var strView = objView.getAttribute('value');

//Self-service view
if (strView == 'ess')
{
g_form.setReadonly('field',true);
}

//Default view (if there is no value specified then it is automatically default)
if(strView == '')
{
g_form.setMandatory('field',true);
}
}

Mark my ANSWER as CORRECT n HELPFUL if it works.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Kam,

Good approach would be to create a client script which is onload and specify the view name

so when onload client script runs and if it is that view then only field will be made as mandatory

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@RudhraKAM 

Hope you are doing good.

Did my reply answer your question?

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@RudhraKAM 

Hope you are doing good.

Did my reply answer your question?

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Regards
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader