Access to the choices global variable in installation-check script?

Is it possible to access the choices global variable in an installation-check script when the package doesn't have choices that the end-user can interact with?

I'm referring to this:

https://developer.apple.com/documentation/installer_js/choice

It seems to imply that you can access the choices global variable, but any attempt to do so fails. For example, take the following:

Code Block
<?xml version="1.0" encoding="utf-8"?>
<installer-gui-script minSpecVersion="2">
<title>My Meta Package</title>
<pkg-ref id="com.md4.myapp"/>
<options customize="never" require-scripts="false" rootVolumeOnly="true" />
<choices-outline>
<line choice="default">
<line choice="myapp"/>
</line>
</choices-outline>
<choice id="default"/>
<choice id="myapp" visible="false" title="this is a test" description="testing one" start_selected="true">
<pkg-ref id="com.md4.myapp"/>
</choice>
<pkg-ref id="com.md4.myapp" version="1" onConclusion="none">mypackage.pkg</pkg-ref>
<installation-check script="version_check()" />
<script>
<![CDATA[
function version_check()
{
title = choices.['myapp'].title;
system.log("Performing custom installation check against version " + system.version.ProductVersion);
system.log("Title " + title);
return true;
}
]]>
</script>
</installer-gui-script>

This results in the following:

Sep 8 15:32:56 THY-01-0236-LT Installer[85217]: IFJS: *** exception: SyntaxError: Unexpected token '['. Expected a property name after '.'.

Is it possible to access the choices global variable in this manner? If so, what is the correct way/syntax to do it?

Thanks in advance!


It's pretty egregious that Apple would have a basic Javascript syntax error on their documentation page like that.

The correct syntax is:
Code Block
title = choices['myapp'].title;

Another quick note: if you print one of the values in choices, e.g. system.log(choices['myapp']); it will print (null) to the installer log, giving you the false impression that every one of these keys has a null value. This is not the case, and you can still access the values' properties, such as title, visible, selected, etc.
Access to the choices global variable in installation-check script?
 
 
Q