file.writeText() not creating file

Solved
CS
Codipack Saas
maatwerkbedrijfbwb

Hi

I've had this script that I run to let the user assign a name to the device. This worked on an older version of Mobicontrol but on the latest version I'm getting an error where the script fails to write to a file.

#!/usr/bin/env js

var file = new mobicontrol.io.File('/sdcard/SOTI/attr_devicename.ini');
mobicontrol.message.createTextPromptDialog('Device name?')
.withQuestionIcon()
.withCallback(onConfirm).show();

function onConfirm(result) {
if (result.inputText != null) {
mobicontrol.log.info(result.inputText + ' is the name of the device');
file.writeText('[DeviceInfo]' + '\n' + 'DeviceName = ' + result.inputText);
mobicontrol.agent.checkIn();
}
}
 
Error Message
2 years ago
Android Scripting
ANSWERS
CS
Codipack Saas
2 years ago

I've resolved the issue, by creating a package with the file already inside and attaching a post install script.
It seems the script is then able to access the file to overwrite when needed.

Device: Zebra VC8300 Android 11

Agent: 15.3.3.1069

Mobicontrol: 15.6

Solution
M
MPMOD@SOTI
2 years ago

Hi Codipack Saas,

That is great to hear that you have found a resolution. Please feel free to post your solution with detailed steps and mark it as resolved.

Please feel free to reach out to us if you have any further questions in the future.

Kind regards,

Technical Support Specialist | SOTI | +1 905.624.9828 | SOTI.net lDiscussion Forum | Log a Case Online l Facebook l LinkedIn l Twitter 

RC
Raymond Chan Diamond Contributor
2 years ago

What are the version and build numbers of your MobiControl device agent?

What about the Android firmware major & minor versions on the device?

What apps permissions have you granted to the device agent?

Have you tried using the same function to write to other directories (e.g. the usual  public directory such as "Downloads" or "DCIM" )?  If so, what are the test results?

M
MPMOD@SOTI
2 years ago

Hi Codipack,

Thank you for posting on SOTI Pulse! 

Are you able to provide the previous MobiControl version and device agent version? It would also help if you could provide some more information on what devices you are working with. If you can also provide the device model, make and the OS, that would be great.

Please also provide what versions you have currently.

Kind regards,

Technical Support Specialist | SOTI | +1 905.624.9828 | SOTI.net lDiscussion Forum | Log a Case Online l Facebook l LinkedIn l Twitter