JavaScript error message "Could not save record because of a compiler error: JavaScript parse error"

ID NOBLE
Tera Expert

Hello,

 

Please I need help fixing the below scripts. It's giving me the following error message "Could not save record because of a compiler error: JavaScript parse error."

I have also attached a screenshot displaying the error message in full with my post.

 

Thank you.

Below are the scripts

 

function onCondition() {

If(g_form.getvalue('asset_id_number_1') = '') {
g_form.setvalue('user_name_1', "");
g_form.setvalue('bn_for_user_name_1', ");

}

If(g_form.getValueue('asset_id_number_2') = '') {
g_form.setvalue('user_name_2', "");
g_form.setValue('bn_for_user_name_2', ");
}

If(g_form.getvalue('asset_id_number_3') = > ›) {
g_form.setvalue('user_name_3', '');
g_form.setvalue('bn_for_user_name_3 ', '');
}

If(g_form.getvalue('asset_id_number_4') = '') {
g_form.setvalue('user_name_4', ");
g_form.setvalue('bn_for_user_name_4', ");
}

If(g_form.getvalue('asset_id_number_5') = ") {
g_form.setvalue(''user_name_5', ");
g_form.setValue('uic_for_ws_user_name_5', ");


}


1 ACCEPTED SOLUTION

Anup Desai1
Mega Sage

Hi @ID NOBLE 

 

Try this.

    function onCondition() {

     if (g_form.getvalue('asset_id_number_1') == '') {
         g_form.setvalue('user_name_1', "");
         g_form.setvalue('bn_for_user_name_1', "");

     }

     if (g_form.getValue('asset_id_number_2') == '') {
         g_form.setvalue('user_name_2', "");
         g_form.setValue('bn_for_user_name_2', "");
     }

     if (g_form.getvalue('asset_id_number_3') == "") {
         g_form.setvalue('user_name_3', '');
         g_form.setvalue('bn_for_user_name_3 ', '');
     }

     if (g_form.getvalue('asset_id_number_4') == '') {
         g_form.setvalue('user_name_4', "");
         g_form.setvalue('bn_for_user_name_4', "");
     }

     if (g_form.getvalue('asset_id_number_5') == "") {
         g_form.setvalue('command_name_of_ws_user_name_5', "");
         g_form.setValue('uic_for_ws_user_name_5', "");
     }
 }

View solution in original post

8 REPLIES 8

Basheer
Mega Sage

Hi @ID NOBLE ,

1. if should be in small case specifically "if" not If

2. You have not closed the main function "}"

3. In if condition it needs to be either "==" or !=" or ">=" and it can't be just a "="

 

 

@Basheer,

 

Which line in the scripts should I fix for your number 2 correction please? You have not closed the main function "}"

 

Thank you.

In the end line

After this line g_form.setValue('uic_for_ws_user_name_5', ");

there should be 2 } } instead you've just given 1 }

 

Hi @ID NOBLE ,

Did these things solve your problem?