Unhandled exception in GlideAjax, Record producer

Aram Sosa
Tera Expert

Hello folks!
I am working on an Legal service delivery project where we have a Record producer, where the first option is "Create new / Update existing". When "Update" is selected, a reference type field is displayed, where you can choose the user's requests that already exist.

The problem is that when I select any of the existing ones, I get this error message "There is a JavaScript error in your browser console"

 

AramSosa_0-1713197213210.png

 

When inspecting the form, in the console I find this:

AramSosa_1-1713197213243.png

Here is the Client Script code:

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) {
        return;
    }

    var COI_CREATE_NEW = 'new';
    var COI_UPDATE = 'update';
    var NONE = '';

    g_form.setReadOnly('create_or_update_coi', true);

    switch (newValue) {
        case COI_CREATE_NEW:
            g_form.setVisible('conflict_type', true);
            g_form.setMandatory('conflict_type', true);

            g_form.setMandatory('coi_record', false);
            g_form.setVisible('coi_record', false);

            break;

        case COI_UPDATE:

            g_form.setVisible('coi_record', true);
            g_form.setMandatory('coi_record', true);

            g_form.setMandatory('conflict_type', false);
            g_form.setVisible('conflict_type', false);

            break;

        case NONE:
            g_form.setMandatory('conflict_type', false);
            g_form.setVisible('conflict_type', false);

            g_form.setMandatory('coi_record', false);
            g_form.setVisible('coi_record', false);

            break;

    }

}

 

Any help is welcome, thank you very much!

3 REPLIES 3

Amit Gujarathi
Giga Sage
Giga Sage

HI @Aram Sosa ,
I trust you are doing great.
Please find the updated code as given below :

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }

    var COI_CREATE_NEW = 'new';
    var COI_UPDATE = 'update';
    var NONE = '';

    switch (newValue) {
        case COI_CREATE_NEW:
            g_form.setReadOnly('create_or_update_coi', true);
            g_form.setVisible('conflict_type', true);
            g_form.setMandatory('conflict_type', true);
            g_form.setMandatory('coi_record', false);
            g_form.setVisible('coi_record', false);
            break;

        case COI_UPDATE:
            g_form.setReadOnly('create_or_update_coi', true);
            g_form.setVisible('conflict_type', false);
            g_form.setMandatory('conflict_type', false);
            g_form.setMandatory('coi_record', true);
            g_form.setVisible('coi_record', true);
            break;

        case NONE:
            g_form.setReadOnly('create_or_update_coi', false);
            g_form.setMandatory('conflict_type', false);
            g_form.setVisible('conflict_type', false);
            g_form.setMandatory('coi_record', false);
            g_form.setVisible('coi_record', false);
            break;
    }
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



The error message keeps appearing...
If I can provide you with more information to solve this, I will be happy to do so.
Thank you

Sagar Pagar
Tera Patron

Hi @Aram Sosa,

 

It appears that the Catalog client scripts are different from the shared scripts. This is with out GlideAjax call.

 

Thanks,

Sagar Pagar

The world works with ServiceNow