- My View
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?
you can have many methods in your ui script and call them directly in any client side component:
UI Script Name - globalMethods
in your client script you can directly call
var value = a();
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
I'm working in the HR scope, so I cannot create global UI Scripts. How would it work for non-global scripts?
I have been following this, as it seems exactly what I need, but no success
This is the code I am using, but I do not get to success. I do not get derp either, so it's not continuing async either... What's going on...
Another update: It seems that ScriptLoader works for Client Scripts, but not for Catalog Client Scripts... fml... Loading a script is something so basic, why is this so difficult and undocumented?
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
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.
Thank you, Kalaiarasan P,
I think it will work as well, i will be trying on both ways, i 'll be back.
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.
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.
How I see it, that's totally not worth the time. That's why we decided to go for the quick and easy solution and that's to do an ajax call instead. From performance point of view there is hardly a difference. But from development point of view, it would take so much longer to do all that.
I know ,
I am completely agree with you, but I would not like, rule out the idea of standardizing that development to use it dynamically on many items as service portal part.