The CreatorCon Call for Content is officially open! Get started here.

UI Script with onLoad and onChange client scripts

exprozor
Tera Contributor

Hello everyone

I've been trying to get a UI script working without not much of a success.

SN's documentation in this regards do not cover all aspects of its potential usage. I've gone through all forum posts here, including: this and many others

Can anyone suggest what am I doing wrong ?
UI Script

<scope> = <scope> || {};

<scope>.<name>= (function initializeLibrary(g_form) {

    var _localVariable = '';

    function _localFunction() {
      //do something
    }

    function _localFunction2() {
       //do something
    }
	
    var functionToCall= function doProcessChanges(fieldName) {
         //call local functions
         //call AJAX
	
	};

    return {
        processPhasingChanges: functionToCall
	};
		
})(g_form);

onLoad Client Script order - 100
ScriptLoader.getScripts('<scope>.<name>.jsdbx');

onChange Client Script: order - 200
tried all variations, such as

  • <scope>.<name>.processPhasingChanges
  • processPhasingChanges
  • <name>.processPhasingChanges

None seems to work. Any help is much appreciated

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

check out these links which have solution

How to call UI Scripts from Client Scripts

[SOLVED] How to call scoped UI script from catalog client script ?

Regards
Ankur

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

View solution in original post

7 REPLIES 7

That's true.

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

Just managed to get it done with the ScriptLoader....
so all in all, if you are using scoped client script with scoped ui script, go with ScriptLoader...
Thank you for your help

@exprozor 

That's correct.

Please share the UI Script you created and how you are calling it from client script so that it benefits future readers as well

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