Is there a way to dynamically display apps from template?

Solved

We have a set of devices which are assigned a mixed set of apps depending on the customer. It is becoming cumbersome to have many different profiles for each set of apps. I'm looking for a way to make my template only show apps that are installed. That way if I have apps A, B and C I could do the following:

Device Group X is assigned a profile containing A

Device Group Y is assigned a profile containing A and another containing B

Device Group Z is assigned a profile containing A and another containing C

Device Groups X, Y and Z all are assigned a lockdown profile that has home screen items configured for all apps, A,B and C

I'd like the template to be able to detect if an App is installed, and if it is not, don't display a button for it.

With the javascript scripting API, I can send a script to detect this:

        if (mobicontrol.app.getInstalledApp("com.google.android.apps.maps").versionCode < 15000) {
            mobicontrol.log.error("The Example app is outdated; aborting script.");

(Discovered here: https://www.soti.net/mc/help/javascriptapi/en/mobicontrol.app.html) However, I can't seem to get that to run via the template. I'm guessing that the javascript API isn't actually available from the template runtime, but any pointers on how to make that work, or any other clever way to detect if an app is installed would be welcome.

All device groups

3 years ago
SOTI MobiControl
ANSWERS
MK
Martin K.
3 years ago

Hello Cliff,

a couple of years ago I made a change in the HTML code of the classic lockscreen to remove the icon and text from an Element where the program is not installed:

<li><A id ="mcd2" href ="<MCLink2>"><img src="<MCExeIcon2>" onerror="document.getElementById('mcd2').style.display='none'" /><div class="txt"><MCDISP2></div></a></li>

So you crteate a lockdown setting with all possible apps and with the code you can supress the display of "empty icons" but you have then just white space. There is no dynamicaly reorganisation of the icons.

Martin

Solution
CH
Cliff Hales
3 years ago

Thank you! This is a lifesaver.

I've been working from this template:

https://github.com/mobilebob/Soti_Dynamic_Template

I think between your solution and fiddling with the dynamic template, I might even be able to hide the white space, but that is relatively low priority.

MK
Martin K.
3 years ago

Hi Cliff,

glad to help. Thank you for the github link, didnt know this project, will look at it.

Martin

ER

Hi Cliff.

I have the same situation. How did you solve it?

Emanuel.

CH
Cliff Hales
2 years ago

My setup is a variation of the template found here: https://github.com/mobilebob/Soti_Dynamic_Template. Just looked at that one again, and it appears current version may have support for specifying hidden for some values, and that may work better than my method. When I worked on this, the hidden option wasn't available.

Here is what I did:

1. Create a lockdown profile with all apps you want to be available.

2. Set up a custom attribute called AppList.

3. Set the AppList attribute for each device group to include the list of apps you want to actually show. AppList will be a comma separated list of app names. Like: App1, App2, Chrome, App3. You'll also want to have profiles assigned so that the apps are actually installed to the correct device groups.

4. Set up the following template: https://gist.github.com/cliffhales/cffdc836d4bc559831b386eb9730f7bb
This template loads that custom attribute AppList that is set at the device group level, splits it out and uses it to decide which icons to show.
I've not worked much in .js, and it probably shows, but it has been working for our system for a while. Nice thing about this setup, is we can move a device between device groups and apps are installed/uninstalled and the lockdown template knows which icons to show based on that AppList value.  You'll also notice that there are a couple hard coded apps that we do not show. (USB and Permissions) - these could probably be handled better with the HIDDEN attribute of the newer version of the https://github.com/mobilebob/Soti_Dynamic_Template template.

Took some setting up to do, but it is working well for us.

One minor thing: We link to an external image for the logo on our template. If a device isn't online when it loads the lockdown screen, the logo doesn't load. Rare enough for us to not be an issue.