How to store common code for UI Action script in a UI Script to be shared by many similar UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2024 03:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2024 05:12 AM
I'm not a fan of UI Scripts. Any JavaScript error in a UI Script can lead to a broken instance. Trust me, I know what I'm talking about. With a broken UI Script in place I wasn't able anymore to log in.
As a workaround, I recommend using an onLoad Client Script which has no code in the onLoad function. But below that empty function you can place any client-side code like a utils class which encapsulates all the required code. As the code is present in the form also the client-side part of a UI Action then can invoke it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2024 06:16 AM
Thanks for the advice and the workaround 🙂
Can you also provide an example "utils class" that i.e returns "Hello world" just as POC?
I'm not so familiar with that kind of construction 😉
Egil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2024 06:27 AM
call method doWhatEverYouWant() in your UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2024 06:55 AM
Sorry, I can't make it work:
UI Action:
Client Script:
Result:
Uncaught ReferenceError: showNewStatusCode is not defined
Can you spot the error?
Egil