Calling UI Macro from client script in Scoped Application

Bala19
Tera Contributor

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

 

9 REPLIES 9

David165
Mega Expert

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:

  1. Create a UI Macro (as you have done) - give it a name with no spaces or funny characters
  2. Build a UI Formatter and include the UI Macro name, with .xml appended, as the Formatter
  3. Add the formatter to the bottom of the form that you want to run the script on
  4. 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.

Bala19
Tera Contributor

Thank you. Could you please elaborate bit?  tried and couldn't succeed. thanks

Hello David,

 

can you please elaborate more.

 

Thanks and Regards,

Prerana

Ankur Bawiskar
Tera Patron
Tera Patron

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

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