Hello everyone,
I'm attempting to install a .pcg package from JavaScript, but it's not working, and I'm running out of ideas on what else to try.
A main JavaScript script is being executed, and it should install a .pcg package with a legacy sendintent script. While it works perfectly when executed from the MobiControl console on the device, encapsulating the script in a package/profile doesn't work. The sendintent from the legacy script never executes.
I've come across this post which seems to have a similar issue but no promising solution.
I based my approach on a post by Raymond Chan that provided instructions for achieving something similar, which I can't find now. He suggested creating packages to be called from other packages with a PRE-script and copying them using a file sync rule. Perhaps I misunderstood, but here's what I did:
- Created a package with a legacy PRE-Script containing the sendintent command.
- Copied the script to the device in an initial configuration package containing various device configuration files. This package is installed several steps before the JavaScript script is executed, so the .pcg package is in its location before being called by the script. I didn't use file sync as Ray suggested; instead, I copied it through another package. I'm not sure if this could be part of the problem.
- The JavaScript script is executed in a package, and I've tried copying the JS code both in PRE-script and POST-script, but in both cases, I have the same problem. The JavaScript code runs correctly, but the intent is never triggered.
- I've also tried setting a pause immediately after the mobicontrol.packages.install statement using the setTimeout(onExit, 30000) method in case the issue is that the execution of the main script ends before the second legacy script is installed, but I still haven't managed to get it to work.
I believe the code is correct because, as mentioned earlier, if I run the code from the scripts section of the web console, it works perfectly.
Am I doing something wrong? Is it possible to achieve what I'm trying to do?
Best regards.