Client script not working DEV vs PROD

Jagadish Sanadi
Kilo Sage

I have below code which is working fine in DEV but not in PROD. Please let me know how can I get this resolved.

 

Thanks in Advacne

 

function onChange(control, oldValue, newValue, isLoading) {

 

    if (isLoading || newValue === '') {

 

        return;

 

    }

 

var maxCharacters = 450;

 

var fieldValue = g_form.getValue('executive_summary');

 

   

 

    if (fieldValue.length > maxCharacters) {

 

g_form.setValue('executive_summary', fieldValue.substring(0, maxCharacters));

 

         alert('Maximum character limit reached. Field has been truncated to ' + maxCharacters + ' characters.');

 

    }

 

}

1 ACCEPTED SOLUTION

Jagadish Sanadi
Kilo Sage

Found issue why it is was not working.

 

But thank you Jaspal and Ankur for your time

View solution in original post

5 REPLIES 5

Jaspal Singh
Mega Patron
Mega Patron

Hi Jagadish,

Are the field/variable name/s similar in both the instances? When you say not working do you get alert or there is no alert at all?

Hi Jaspal,

 

Alert message comes in PROD but when I click on okay, it must truncate the characters after 450 but it is not happening. Instead alert message keeps poping up and I am unable to close the alert message 

Ankur Bawiskar
Tera Patron
Tera Patron

@Jagadish Sanadi 

it seems it's getting into loop everytime you are validating and setting the value

you should try to replicate it in dev so that you can debug it further

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

I tried in DEV but it now looping as it is looping in PROD.

 

Same test characters were passed in both instances