How can I set zoom property?

I want to change the zoom property value of the document.

        const result = await batchPlay(
         [
            {
               "_obj": "set",
               "_target": [
                  {
                   "_ref": "zoom",
                   "_enum": "ordinal",
                   "_value": "targetEnum",
                   }
               ],
               "to": {
                  "_unit": "percentUnit",
                  "_value": 0.5
               },
               "_options": {
                  "dialogOptions": "dontDisplay"
               }
            }
         ],{
            "synchronousExecution": false,
            "modalBehavior": "fail"
         });
         

I wrote the code, but only the message window says “Set command is not available”.
Please help me.

I’d also love to figure out how to set the zoom level to an arbitrary zoom percentage

For setting the zoom to an arbitrary value, this works for me:

    await batchPlay(
      [
        {
          _obj: 'setPanZoom',
          _target: [{ _ref: 'document', _id: docId }],
          x: { _unit: 'pixelsUnit', _value: centerX },
          y: { _unit: 'pixelsUnit', _value: centerY },
          z: { _unit: 'percentUnit', _value: zoomScale },
          resize: false,
          animate: false,
          _options: { dialogOptions: 'dontDisplay' },
        },
      ],
      { synchronousExecution: true }
    );

Note that even though the label says “percentUnit” it is a scale factor (e.g. 1.0 for 100%).