Fields Mandatory

Naveen87
Tera Guru

Hello Developers,

 

I wanted to make few fields mandatory while closing the stask.

I used below script & it is working fine.

But I also want to add few things like, If user is in a different view where these fields are not visible on form then these should not be mandatory.

 

Do we have any line of code which check, If these fields are on the form?

If yes, then fill them(mandatory)

If No, ignore (non-mandatory)

Naveen87_0-1724663053421.png

function onSubmit() {
    //Type appropriate comment here, and begin script below

    var state = g_form.getValue('state');
    var solution = g_form.getValue('u_solution');
    var assign = g_form.getValue('assigned_to');

    if ((state == 3 || state == 10) && (solution == '')) {
        g_form.showFieldMsg('u_solution', 'Please fill solution before closing the Task', 'error');
        //	alert('Please fill solution field before closing the Task');
        return false;
    }
    if ((state == 3 || state == 10) && assign == '') {
        g_form.showFieldMsg('assigned_to', 'Please fill Assigned to before closing the Task', 'error');
        return false;
    }

}

 

Thank you

 

1 ACCEPTED SOLUTION

You can use the below like to check if the field is present on the form(current view)

 

 g_form.hasField('<your field name>') //returns true fi field is present, false if it is not

-Anurag

View solution in original post

14 REPLIES 14

You can use the below like to check if the field is present on the form(current view)

 

 g_form.hasField('<your field name>') //returns true fi field is present, false if it is not

-Anurag

@Naveen87 did you see this?

-Anurag

Oh yeah.

Looks like this worked.

Naveen87_0-1724669837232.png

 

I tried this but did not work.

Naveen87_0-1724668834883.png