- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2022 06:17 PM - edited ‎11-29-2022 09:05 PM
I need to run field auto-fill and validation for all catalog items.
So I made a common UI Script.
I try to call UI Script in Client Script but It shows this error message "(g_env) [SCRIPT:EXEC] Error while running Client Script "[Catalog Client Script Name]": ReferenceError: [UIScriptName] is not defined" in Service Portal.
Is there no way to call UI Script from Catalog Client Scripts for Service Portal?
UI Script :UIScriptName
var UIScriptName = Class.create();
UIScriptName.prototype = {
......
validate: function(value) {
var result= true;
.....
return result;
},
.....
};
Catalog Client Script onChange
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
return new UIScriptName().validate(newValue);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2024 10:42 AM
Hi Joy,
In case you haven't yet found an answer, this post may help:
Apparently, this solution is specific to calls from Service Portal, and apparently won't work if the call is made from the Native UI, such as through the Record Producer "Try It". Still looking for a solution for the latter. 😕
Good luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2022 06:44 PM - edited ‎11-29-2022 06:45 PM
Hi @Joy715 ,
Try this in your catalog client scripts -
var result = UIScriptName().validate(newValue);
return result;
Also, take a look at - Call UI script from an Onload Catalog client script
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2022 08:24 PM
Hi! Thank you for your answer.
but it doesn't work..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2022 08:35 PM
Hi @Joy715,
Have you added UI scripts in Service portals theme?
if not, please add it as follows. It will work.
Navigate to Service Portal > Themes and select the theme being used (Stock is the default).
Then, add the UI Script via the related list JS Includes at the bottom of the form (New).
Note - UI Scripts ran from Service Portal have no access to g_form.
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2022 08:44 PM
yep I did that... still same error ðŸ˜