Get a list of all mandatory fields portal

Snow Tomcal
Tera Expert

Hi All,

I want to get a list of all mandatory fields in the portal.

Does anyone know how to do it? 

 

Thanks in advance 🙂

11 REPLIES 11

I'm using a client script

Community Alums
Not applicable

Hello @Snow Tomcal ,

 

In clientscript we have g_form.isMandatory('field_name'); it returns true if field is mandatory and false if field is non mandatory.

 

Thanks!

I need all the fields that are mandatory, not just one.😑

Hello @Snow Tomcal 

 

You can write a onLoad() Client Script :-

 

 

function onLoad() {
var fields = [];
for (var i = 0; i < g_form.elements.length; i++) {
if(g_form.isMandatory(g_form.elements[i].fieldName))

fields.push(g_form.elements[i].fieldName));

}
alert("Mandatory Fields are : "+fields);
}

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Regards,

Samaksh

Now I get - TypeError: Cannot read property '0' of undefined.