Calling UI Macro from client script in Scoped Application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2019 09:56 PM
Hello All,
Does anyone now how to call the UI macro from catalog client scripts in scoped application?
I see somewhere ref_contributions has to be added. But not sure how to add the same?
UI Macro
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<html>
<head>
<script>
function checkDetails()
{
alert('Hello');
}
</script>
</head>
</html>
</j:jelly>
Catalog client Script
function onLoad() {
checkDetails();
}
Thanks
Bala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2019 01:52 AM
Hi Bala
I think I've just done something similar in a scoped application I am working on. These are the steps I had to use to get it to work:
- Create a UI Macro (as you have done) - give it a name with no spaces or funny characters
- Build a UI Formatter and include the UI Macro name, with .xml appended, as the Formatter
- Add the formatter to the bottom of the form that you want to run the script on
- Make sure your Client Script has Isolate Script deselected. You might have to edit the client script form to add the Isolate Script field.
I hope this helps. It took me several weeks trial and error to get it to work for me.
Regards
David
Please remember to mark this reply as Helpful or Answered if it solves your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2019 06:55 PM
Thank you. Could you please elaborate bit? tried and couldn't succeed. thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2020 10:27 AM
Hello David,
can you please elaborate more.
Thanks and Regards,
Prerana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2019 08:02 AM
Hi Bala,
yes you can call the UI macro function within the onLoad, onChange client script
the above syntax should work; provided you include that UI macro variable on the catalog item as a variable
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader