Understanding "UI Type" and "Applies On" Checkboxes

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 06:29 AM
As you know, Catalog Client Scripts have the infamous "UI Type" dropdown, and 3 separate checkboxes for where the script applies. Like this:
Question 1)
Does this mean that there are truly 6 separate contexts in which the script may run? As follows:
Desktop Catalog Item
Desktop Requested Item
Desktop Catalog Task
Portal Catalog Item
Portal Requested Item
Portal Catalog Task
Question 2)
Since I like to minimize work, I would generally be selecting UI Type "ALL", so that I only have ONE VERSION of my script, and if there is a bug or if something needs to change, the developer coming behind me will only have to change things in one place, one time. That is a software engineering principle, right? Avoid dual maintenance. (Don't copy and paste code.) Correct?
Question 3)
But isn't it also true that different objects are available in different contexts? Not all API functions are guaranteed to work on the Serviced Portal. So... I need to know what context my code is running in, don't I? Because 90% of my script might apply on both the Portal and the Platform UI, but 10% might be different. So there should be a flag which I can check at runtime which makes it easy for me to know what context my code is running under, right? What is that flag??? Certainly I don't need to do anything weird like unchecking "Isolate Script" in order to determine my context, right?
Thanks to anyone who can provide context and shed some light on these questions. Very much appreciated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 06:16 AM
@nowgpt1 Than you for that excellent answer...
Regarding g_form.getTableName()... Wouldn't I need to have all kinds of code to check multiple table names? I really just want an isPortal flag, but I want it to work WITHOUT needing to uncheck the Isolate Script checkbox. Why is that not available? Are other people not running into this problem?
I feel like I'm doing something wrong, because simple flags such as this are NOT available.