Download a data file (.csv) using javascript

Solved
JB
J. B.
LGI Logistics Group International GmbH

Hi all,

we have the problem, that we need to change an ini file and put in an number that is related to the device name. We use Zebra TC21 and MC33xx with Android 10 an 11.

For the translation from device name into the number we would download an csv file with both values and read the values. Most of the script works, at the moment we are stuck in downloading a file. On the web are a lot of descriptions, but i did not find one that works.

Is someone out there who has an idea to that?

Best regards
Jürgen

2 years ago
Android Scripting
ANSWERS
RS
Rafael Schäfer
2 years ago

I think there's nothing in javascript currently (Documentation) but you could do it via filesync rule or legacy httpget to prepare the devices with the files and later run your javascript.

You could also put both in a package (Legacy with httpget as pre-install and a sleep and Javascript as an Post-Install Script) but still a risk maybe that the file is not there when the javascript starts.

Can't choose javascript as an option in MCStudio

Solution
TG
Thomas G.
2 years ago

i'm not sure (and have not tested it), but maybe its enough to start the JavaScript with this "shebang"

 #!/usr/bin/env js
JB
J. B.
2 years ago

Hi Thomas,

Thanks for you answer. The shebank is already in first line of the script.

JB
J. B.
2 years ago

Hi Rafael,

Thank you for your answer. The datafile changes without information to us (IT). So it should be automated to be retrieved at the moment of the installation of the apk. We dont have a server for filesync. I will have a look on the httpget, that i did not know of.

RS
Rafael Schäfer
2 years ago

Just to add it here, if you want to execute a javascript via package, you could maybe provide it as a file (*.js) with an auto execute afterwords. But never tested/tried yet because we needed only legacy scripts in the past.

JB
J. B.
2 years ago

Yes exactly thats how we do it.

M
MPMOD@SOTI
2 years ago
JB
J. B.
2 years ago

Hi MPMOD,

no, there is no solution in javascript at the moment. So i realized the mixed function with legacy script and javascript. That works for now, but is just a workaround.

Best regards,

Jürgen

M
MPMOD@SOTI
2 years ago

Hi J. B.,

If there are no solutions in javascript, could you please explain in more detail about this workaround and possibly post an image about the workaround?

Also, if any particular post helps you in resolving this, please feel free to mark it as the solution.

Kind regards,

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

JB
J. B.
2 years ago

Hi MPMOD,

the workaround is to have two scripts inside the package:

1. In the Pre-Install script I used legacy scripting to download the needed files with httpget.

2. In the Post-Install script I inserted the javascript that uses the uploaded files.

The Tipp to do it like this was the first answer on my question, I marked it as answer.

Best regards,
Jürgen

M
MPMOD@SOTI
2 years ago