Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Unable to properly call a UI Script from a Catalog Client Script.

RyoyaFukuda
Tera Contributor

Hi,all.

I am trying to call a UI Script from a Catalog Client Script.
This development is being done within a custom application.

Here is the script. And error message is ''UI Script  x_16799_test.TestUIScript is loaded but can not find dummyFunction or result is fraud. Result: null'
Could you please tell me why the UI Script cannot be called successfully?


Catalog Client Script
Type : onChange

UI Type : All

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

    var value = newValue;
    var name = 'u_int_test';
    var uiScriptName = 'x_16799_test.TestUIScript';


    if (typeof g_ui_scripts !== 'undefined') {
        // Workspace(WEP)
         g_ui_scripts.getUIScript(uiScriptName).then(function(result) {
        if (result && typeof result.dummyFunction === 'function') {
		//  if (result && typeof result.formatAndTruncateNumber === 'function') {
            g_form.addInfoMessage('UI Script ' + uiScriptName + ' is loaded and find dummyFunction');
            result.dummyFunction();
        } else {
            g_form.addInfoMessage('UI Script ' + uiScriptName + ' is loaded but can not find dummyFunction or  result is fraud.  Result: ' + JSON.stringify(result));
        }
    }).catch(function(error) {
        g_form.addErrorMessage('UI script failed to load: ' + error);
    });
    }
}



UI Script
API:x_16799_test.TestUIScript

(function() {
    return {
        dummyFunction: function() {
            // do noting
        }
    };
})();

 

10 REPLIES 10

@Ankur Bawiskar 
I modified the code in the same way as the code described in the knowledge base I received, but I got an error message saying "Cannot read properties of null (reading 'dummyFunction')"