How to run UI Script from Catalog Client Script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2017 07:55 AM
Sorry for such a basic question, but I'm not seeing it. It must be the time of day.
I created a UI Script, which is not global as I'm working in the HR scope. It has a custom made function sn_hr_core.gdf_hr_check_input, which returns another function.
So I thought I should call it by typing sn_hr_core.gdf_hr_check_input.checkRecordProducer(input) in the Catalog Client Script and that it would be loaded correctly. It seems I was wrong. Should I add some inclusion code maybe?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2017 09:54 AM
Hello Peter Raeves , fortunally i have a really good solution to what you are trying to do.
First of all, if you create an ui script that is not global, it means that you wont be able to aceess to those (functions, objects or variables) from any catalog item or record producer that you are accessing, so.
What you need, is to specifically use this ui script in the catalog item or record producer from our catalog scripts, and you can do it by simple adding a new varaible or variable set to your catalog or record producer to grant access to that script.
That variable should be macro type, in order to use the ui script in from your ui macro.
The following code is an example of what you have to add your ui macro to requiere your ui script, same which is not in the global scope .
As you can see in the image we have to use the g:requiere tag to requiere our ui script that we previuosly have created, also notice this is a ui macro wich is going to be add to the variable of type macro that we have added to our catalog item or record producer
So, what do we have to do, to return a function from our ui script that is not in the scope, and we want to access from our catalog item?
Well first of all we have to define our script in the ui script
We are accessing to a private function wich is going to return a simple alert, that is called from the main function is automatically returned to our object wich is named as x_98229_sn_hr_core, so.
Now you can use this object in your catalog scripts, For example, lets print our alert message on a catalog script when the record producer is loadded .
As you can see we are accessing to our ui script function through accessing from our x_98229_sn_hr_core object in this way the result is going to be an alert message from the browser when the pages is loaded
I hope this post was helpful for you, dont forget to point this answer as useful, and give me your like
JA.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2017 01:24 AM
I used to use the following to invoke UI script on UI pages. But not sure if this works in scoped app or not. You can give this a try.
<script></script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 07:30 AM
Thank you, Kalaiarasan P,
I think it will work as well, i will be trying on both ways, i 'll be back.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 12:55 AM
Could you try to open your record producer on the HR Service Portal please? (or any other portal probably). Because I think I tried this before (or at least something similar, like adding variable sets), and it did work on the service catalog, but not on the portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 07:17 AM
Hello Peter,
You wont be able to add macros on service portal.
I have tryed to do that as well, but i was not able to work in that way.
I will say this is like a different proyect of what you are trying to do.
Insted consider to use widgets.
You can use an embeded witgets for what you are trying to do.
In that way maybe you can avoid the sc catalog item widget being rendered with the default tag and then use custom widget, i am still working on some kind of development like this, and also consider the use of angular as front end, due to everything on service portal was built on ajs.
I hope this have had helpful for you, dont forget to point the answer if so.
JA.