Unable to properly call a UI Script from a Catalog Client Script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
}
};
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I am developing a custom application named "Test."
Catalog Client Script and UI Script applications are both "Test".
Do you need any other information?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Can you validate your UI script code. I guess type is missing there.
- Application: x_16799_test
- Name: TestUIScript
- API Name: x_16799_test.TestUIScript
(function() {
return {
dummyFunction: function() {
alert("Hello from Scoped UI Script!");
},
type: "TestUIScript"
};
})();
- Then initially keep your code simpler (without validation) and test. Once call is successful, add all validation.
- Add Alert to check where it is not responding.
- For UI script load you can try with ScriptLoader as well
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Call the UI script function asynchronously
g_ui_scripts.getUIScript('x_16799_test.TestUIScript').then(function(result) {
// Access the function defined in the UI script
result.dummyFunction();
}).catch(function() {
// Handle cases where the script fails to load
console.error('x_16799_test.TestUIScript did not load');
}); }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I tried your code.
I got an error message and confirmed that the UI script was not called correctly.
