Clear cache on applications

Solved
BR
Billy Rhea
AutoZone, Inc.

So currently I have a clear cache script that i deploy to our devices via a profile and it puts clearcache.scr file in the root of the device and i have an icon on the lock screen to call this script and it will clear cache on the selected applications. What I am trying to figure out is there a way i can have a prompt in this script that if they answer yes it runs and if they answer no it will just exit? 

The current contents of the clearcache.scr file is below:

wipeapplication com.overvyoo.client
sleep 1
wipeapplication com.dar
sleep 1
wipeapplication net.soti.surf
sleep 1
wipeapplication com.android.chrome
sleep 1

a year ago
Android Scripting
ANSWERS
RK
Radim Kadlec
a year ago

The following javascript should do what you need:

mobicontrol.message.createYesNoDialog('Do you want to clear app data?').withCallback(onConfirm).show();

function onConfirm(result) {
    if (result.buttonIndex == 1) {
        ClearAppData('com.overvyoo.client');
        ClearAppData('com.dar');
        ClearAppData('net.soti.surf');
        ClearAppData('com.android.chrome');
    }
    else {
        mobicontrol.log.info('User chose not to clear the application data');
    }
}

function ClearAppData(MyApp) {
    var result = mobicontrol.app.installedApps.filter(app => app.packageName == MyApp).length;
    if (result > 0) {
        mobicontrol.app.clearData(MyApp);
        mobicontrol.log.info(MyApp + ' data wiped');
    }
    else {
        mobicontrol.log.info(MyApp + ' is not installed');
    }
}

Solution

I think you should be able to do this via javascript instead of legacy.

Just to add: You can implement this functionality entirely in the lockscreen template (would be then a Button or so to be tapped on) then, if you want instead of providing a seperate script (if you think it won't be changed and/or your template is not used somewhere else.

C
CKMOD@SOTI Bronze Contributor
a year ago

Hi Billy,
 
Thanks for posting on SOTI Pulse, Thanks Radim and Rafael
for responding to the post, your expertise and willingness to help are greatly appreciated!
 
Have you had an opportunity to test the suggested solutions by Radim and Rafael and has it successfully addressed your query?
 
If not, or If you have any additional questions or concerns, please don't hesitate to reach out. We're dedicated to providing assistance and support.

BR
Billy Rhea
a year ago

Yes thank you both for your response and help with this issue. I am in the process of testing this today and thank you again for your input on this issue we are facing. 

C
CKMOD@SOTI Bronze Contributor
a year ago

Hi Billy,
 
Thanks for posting on SOTI Pulse.
Thank you, Rafael and Radim, for responding to the post, your expertise and willingness to help are greatly appreciated.
We are glad to know that your issue has been resolved. If you have any additional questions or concerns, please don't hesitate to reach out. 
We're dedicated to providing assistance and support.