Skip to content

Combine page parameters, scripts, and data export | Mingcedar Studio

Check script scope and execution limits, then configure page and popup parameters, type conversion and troubleshooting.

Script methodsFeatureDocumentation revised: 2026-10-21
Feature

Combine page parameters, scripts, and data export

Check script scope and execution limits, then configure page and popup parameters, type conversion and troubleshooting.

Start with the five script locations

Code location determines scope, execution timing, and async/write permissions. Mingcedar Studio has no global script document spanning all pages.

  • Page Script: belongs to the current page. Top-level var, let, const, class, and function declarations are available to animations and expressions on that page.
  • hqVisuDesignerPageReady(ctx): runs once after the page runtime is ready and suits component initialization; constants and helpers needed by the first animation evaluation still belong at Page Script top level.
  • Setup Script: prepares variables and intermediate results for one behavior only; it is not a page-global area.
  • Condition / Value / Display Text / Fill / Border / Visibility / Source value: synchronous expression slots that must immediately return one result.
  • Click / Hover / Press-Release Script: full event-driven script bodies. WriteTag is allowed only for a genuine Click, Press, or Release; Hover cannot write device data.
Recommended animation-script split

Keep shared Tag prefixes, ranges, and conversion functions in Page Script. Color and text behaviors that provide Setup Script can prepare local results there. Move, Rotate, and Scale have no Setup Script or Post Operations field. Put reads and conversions directly in Source value or Rotation input and reusable helpers in Page Script.

// Current Page Script
const tankTagPrefix = "PLC_LINE01.TANK01";
function percent(value, min, max) {
  return Math.max(0, Math.min(100, (value - min) * 100 / (max - min)));
}

// Scale: Source value
percent(ReadTagDouble(tankTagPrefix + ".LEVEL", 0), 0, 10)

// Source minimum / maximum: 0 / 100
// Limit minimum / maximum: 0 / 100
// At limit minimum / maximum: 0 / 1
// Moving edge: Top
Synchronous, asynchronous, and write boundaries

Do not put fetch, Promise, setTimeout, or setInterval directly in an expression slot because animation evaluation needs an immediate result. Prepare asynchronous data in an async function in Page Script, hqVisuDesignerPageReady, Click Script, or Hover Script, then expose a page variable or host data source for the animation to read. await is valid only inside an async function; top-level await and import/export module syntax are unsupported. Device writes require a genuine user click, press, or release and remain subject to host permission, confirmation, reason, and audit controls.

Navigation parameters: supported content

In Open Link, select Internal page to enter values under Parameters (optional). For other Destinations, fill the fields for that target type. Scripted navigation passes parameters in the second hqVisuDesigner.openPage argument. Values may be strings, numbers, booleans, or null; the destination reads strings and reads null as an empty string.

  • parameters must be an array whose entries have { key, value }.
  • The array preserves order and repeated keys. A plain object is not the formal openPage parameter shape.
  • frameTarget supports frame, fullscreen, and _blank; openInNewWindow: true is equivalent to _blank.
  • Use openPage within one package. Use openScreen(screenCode) across packages, but generic Jump Parameters are not guaranteed across a screen-package boundary.
  • Website / File URL parameters become URL query values and are read according to the destination system's query rules.
hqVisuDesigner.openPage("device_details", {
  frameTarget: "frame",
  parameters: [
    { key: "PLC", value: "PLC_LINE01" },
    { key: "Device", value: "PUMP_01" },
    { key: "Mode", value: 1 },
    { key: "Enabled", value: true }
  ]
});
Destination reads and type conversion

Read parameters in the destination Page Script and validate before use. GetPageParameter returns the first matching value; GetPageParameterValues returns every value for a repeated key; GetPageParameters returns every { key, value } in original order. All three also have hqVisuDesigner namespace forms. Every read value is a string, so explicitly convert numbers and booleans and constrain allowed characters before building a Tag name.

var plc = GetPageParameter("PLC", "");
var device = GetPageParameter("Device", "");
var modeText = GetPageParameter("Mode", "0");
var enabledText = GetPageParameter("Enabled", "false");

if (!/^[A-Za-z0-9_-]{1,64}$/.test(plc) ||
    !/^[A-Za-z0-9_-]{1,64}$/.test(device)) {
  throw new Error("Invalid page parameter");
}

var mode = Number.parseInt(modeText, 10);
var enabled = enabledText === "true";
var statusTag = plc + "." + device + ".STATUS";
Popup parameters and close results

The static Open Page as Popup input accepts a JSON object, not a top-level array. With Build page parameters with an expression enabled, the runtime accepts an object or an ordered array of { key, value } entries; use an array for repeated keys. The popup destination still reads values through GetPageParameter*. Close Current Popup's Result expression is a reverse result channel from the popup to its opener and may return a boolean, number, string, or object; it is separate from the query parameters used to open the popup.

Count, length, and security limits

The Runtime keeps at most 64 navigation parameters. A key is limited to 256 characters and a value to 2048 characters; invalid entries are ignored. Parameters enter the URL query and must not carry passwords, tokens, authorization proof, sensitive personal data, or large JSON payloads. Cookie, localStorage, and sessionStorage depend on origin, iframe, and host loading details and are not a formal cross-page parameter protocol. Page parameters cannot expand host-granted Tag, page, or user permissions.

Separate four value mechanisms and troubleshoot in order

Template variables, Runtime Variables, PLC Tags, and page parameters solve different problems. Template variables are substituted on an instance and before export; Runtime Variables link state on the current page; PLC Tags belong to the host data layer; page parameters carry context only when a destination is opened. If a read is empty, check whether the target type supports parameters, key spelling and case, whether parameters is an array, count/length limits, whether the host took over navigation, whether the destination URL contains the query, and whether a cross-package relative path was used by mistake.

1. Export structured JSON

ExportJson(value, fileName?) exports an object, array, or other serializable value. Its default filename is export.json. Strings remain strings. Read a JSON Tag with ReadTagJson first when exporting its structured value.

ExportJson(
  ReadTagJson("PLC_LINE01.REPORT01.SUMMARY", null),
  "line01-production-summary.json"
);
2. Export a current-page data table

ExportTable(nameOrId, fileName?, format?) supports built-in data tables on the current page. Formats are csv, json, xlsx, and excel (an xlsx alias), with CSV as the default. Supply the Table component's Name from Behavior Browser or its shapeId, with matching case. Use a unique component name; the displayed Table name is a title and cannot locate the component. The export includes all currently bound rows, including rows outside the scroll viewport, and preserves cell display text.

ExportTable("Line01ProductionTable", "line01-production.csv", "csv");
ExportTable("Line01ProductionTable", "line01-production.xlsx", "xlsx");
3. Export current Tag values and quality

ExportTags(tagNames, fileName?, format?) accepts one Tag name or a non-empty name array. It supports csv, json, and xlsx, defaulting to CSV. It exports current values without querying history. CSV / XLSX columns are Tag, Value, Quality; JSON records contain name, value, quality.

ExportTags(
  ["PLC_LINE01.PUMP01.SPEED", "PLC_LINE01.PUMP01.RUN"],
  "line01-pump-status.json",
  "json"
);
4. Preconditions and result meaning

Start downloads from a user click after data is loaded and the page has permission to read the relevant Tags. A returned filename confirms that downloading was initiated, not that the file was saved. Files go to the browser download location, not an Mingcedar server directory.

  • Missing tables, unavailable Tags, and unsupported formats report errors instead of substituting zero.
  • Existing poor-quality values retain their quality label and are not valid field readings.
  • JSON distinguishes numbers, booleans, and null. Table exports use display text.
  • The browser or host can restrict downloads. Check page feedback and download permissions when an export fails.

Click the image again or press Esc to close