Client Script Issues running twice in SOW

johndoh
Mega Sage

Can anyone help me understand why this simple script is causing the info message to be displayed twice only within SOW?

 

johndoh_1-1743464837664.pngjohndoh_2-1743464868874.png

johndoh_0-1743465042362.png

 

I should add there is no other onChange client scripts that are associated with this field. Checking or unchecking isolated script appears to make no difference once so ever.

1 ACCEPTED SOLUTION

johndoh
Mega Sage

From our SOW admin:

 

I went and duplicated the new record page and checked the whole duplication issue after and everything seems to be working just fine now.

View solution in original post

13 REPLIES 13

Vishal Jaswal
Giga Sage

Hello @johndoh 

I am only able to reproduce the issue when I select Email as Channel twice however in between select a different Channel choice; so modified the onChange Client script a bit:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || isTemplate) {
        return;
    }
    //Type appropriate comment here, and begin script below

    if (newValue === 'email') {
        console.log('Testing');
        g_form.addInfoMessage('Testing');
        g_form.setValue('description', 'test');
    } else {
		g_form.clearMessages();
	}
}

Try playing with UI Type to see if it makes any difference!



Hope that helps!

johndoh
Mega Sage

Same issue:

 

johndoh_0-1743468586634.png

I can confirm that I am only selecting the email channel once. This also seems to happen with the State field for me but there are other client scripts, so I created this to see if there was a conflict.

 

If I change the type to desktop the info messages arent dispayed as designed as this SOW. If I change to Mobile/Service Portal both are displayed.

 

Just to make sure I did perform a cache.do and also made no difference.

Ankur Bawiskar
Tera Patron
Tera Patron

@johndoh 

did you try creating a fresh client script and see?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

The fresh script is what is on this thread, my original script is much more in-depth and uses the state field instead but like your thought was trying to eliminate possibilities. I will note I am in a domain separated environment and if history has taught me anything is most likely the cause 🤣 but if global or domain I get the same outcome.