How to run UI Script from Catalog Client Script?

peterraeves
Mega Guru

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?

Image 7.png

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Peter,



you can have many methods in your ui script and call them directly in any client side component:



example:



UI Script Name - globalMethods



function a(){


return 'test';


}



function b(){



}



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.


Thanks


Ankur


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

I'm working in the HR scope, so I cannot create global UI Scripts. How would it work for non-global scripts?


peterraeves
Mega Guru

I have been following this, as it seems exactly what I need, but no success


Client-side GlideRecord replacement for Scoped Applications (sort of)



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...


Image 11.png


peterraeves
Mega Guru

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?