Incident form

Venky Kshatriy2
Tera Contributor

Hi Team,

 

I am facing problem on Incident form I have different view's (like view1 , view2,view3....) and in every view few fields are mandatory , Right now view1 is active ,end user filed the all fields in view1 after fill the form end user click the submit button ,I need to check the view2 field values  if the field is empty in view 2 I need to show the error.....

 

 

any suggestions 

1 ACCEPTED SOLUTION

Deepak Shaerma
Kilo Sage

Hi @Venky Kshatriy2 
please go for On submit client script on incident table to show error when user tries to submit the form, check for all mandatory field in all views.

var fieldsToCheck = ['field_in_view2', 'another_field_in_view2']; //put fields backend name from all views.
    var errorMessage = 'Please fill out all mandatory fields in other views: \n';
    var fieldMissing = false;

    // Iterate over the fields to check if they are filled
    fieldsToCheck.forEach(function(fieldName) {
        var fieldValue = g_form.getValue(fieldName);
        if (!fieldValue) {
            // If the field is empty, append the field’s label to the error message
            errorMessage += g_form.getLabelOf(fieldName) + '\n';
            fieldMissing = true;
        }
    });

    // If any field is missing, show an error message and prevent form submission
    if (fieldMissing) {
        alert(errorMessage);
        return false; // Return false to prevent form submission
    }

    return true;

Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma 


View solution in original post

2 REPLIES 2

Deepak Shaerma
Kilo Sage

Hi @Venky Kshatriy2 
please go for On submit client script on incident table to show error when user tries to submit the form, check for all mandatory field in all views.

var fieldsToCheck = ['field_in_view2', 'another_field_in_view2']; //put fields backend name from all views.
    var errorMessage = 'Please fill out all mandatory fields in other views: \n';
    var fieldMissing = false;

    // Iterate over the fields to check if they are filled
    fieldsToCheck.forEach(function(fieldName) {
        var fieldValue = g_form.getValue(fieldName);
        if (!fieldValue) {
            // If the field is empty, append the field’s label to the error message
            errorMessage += g_form.getLabelOf(fieldName) + '\n';
            fieldMissing = true;
        }
    });

    // If any field is missing, show an error message and prevent form submission
    if (fieldMissing) {
        alert(errorMessage);
        return false; // Return false to prevent form submission
    }

    return true;

Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma 


Hi @Deepak Shaerma 

 

Thanks for your reply it's working fine. In above script we are giving the field name instead of shell we use dynamic like (taking the all mandatory field's and it will check the only mandatory fields ) if the mandatory field is not field we need to show the error.....

 

Regrading this any  suggestion..