Skip to content

Declaring variables with context

At a glance

  • Context has two tabs: Environment Variables (values you declare once and reuse) and Iterators (for repeating data).
  • An environment variable is built the same way as any other entry — pick a type, give it a value.
  • An iterator can be built manually as a graph or code, or you can let MorphMapper's AI suggest one for you.

Some entries have a Context view alongside their usual editor — open it from that entry to declare values you want to reuse, rather than rebuilding the same logic in multiple places.

The Configure Template Context screen, with Environment Variables and Iterators tabs; the Environment Variables tab open, listing declared variables like Client reference, Invoice reference, and Trucking Company with an Add button above the table

Environment variables

This tab is a tree of declared variables, built the same way as the entry list itself — add one with the same + button, give it a type and a name, and (if it's a group) how its children combine. Its header text, verified live: "Environment variables are used to define common occurring values, so that they can be reused across multiple definitions inside node configurations." Once declared, a variable becomes available for other fields to reference instead of selecting a fresh value from the file each time — see Selecting values from the source file for how that reuse shows up when you're filling in a field elsewhere.

The + button opens the same Create New Entry modal used everywhere else in the entry tree (see Working with entries): a Type dropdown (Boolean, Simple, Graph, Cell, Map, Code), a Name field, and — only when Type is Map — a Map Type dropdown grouped into core (Group, Array Group) and iterator (For Each, Data Object) options, the same four choices as the Iterators tab's Map Type picker below.

Variables can be nested: creating a Map-typed (group) variable and opening it — click its row's first action icon — doesn't expand a sub-list in place. It navigates to a separate Configure Context screen for that variable specifically, titled "Configure <name> Context", with its own Environment Variables and Iterators tabs scoped to that group's children. Use the back arrow next to that header (left of "Configure <name> Context") to return to the parent context.

Iterators

An iterator is for data that repeats — rows in a table, or any structure where the same shape occurs more than once in your source file. This tab's own header text, verified live: "Iterators are used to extract values which are represented in a repeating structure. Iterators can be referenced in the graph of nested variables." It's grouped under a General heading and lets you set one up for the current entry:

  • Map Type — how this entry's children combine (the same choice you'd make when creating a group entry; see Working with entries). It's shown as a button labeled with the current choice. Clicking it opens a full Select Component screen, the same categorized block list as the node picker in the graph editor, not a simple dropdown, with two categories to pick from: Core (Group — "Group the descendant values by the given key.", Array Group — "Group the descendant values by the given key into an array.") and Iterators (For Each — "Fills the descendant values for each item in the given array.", Data Object — "Use this block to create a data object, this data object can then be used by other iterator structure blocks."). Changing the Map Type doesn't remove or reset an iterator you've already built for this entry — the two are independent.

    Select Component screen opened from the Iterators tab's Map Type button, showing a Core category with Group and Array Group blocks, each with a description, and a collapsed Iterators category below

  • Iterator — the logic that identifies each repeating occurrence, built either as a graph (choose from iterator-specific blocks like counting occurrences, pulling from a list, or iterating a whole table) or written directly as code. Once one exists, you can edit it, remove it, or switch which type it's defined as.

The Iterators tab of the Configure Template Context screen, showing a Map Type of "Group" and an "Iterator (Graph)" section with add, switch-type, and more-actions icons, before any iterator has been built

Before any iterator exists, the row shows three icons: Add, the AI suggestions atom, and an Options menu. The Add icon opens a menu titled Iterator type listing the same iterator-category blocks as the graph editor's node catalog: Count Occurrences, Iterate Table, Get From List, Sum From List, and Container Iterator. Picking one immediately creates a graph-type iterator for this entry and navigates straight into its own graph editor — with that node already placed and wired to the graph's terminal node, breadcrumbed as #iterator — rather than dropping you back on this Context screen. The separate Options menu, available even before an iterator exists, holds a Type choice between Graph and Code: switching it to Code changes the Add icon into a direct "create as code" action instead of opening the iterator-type menu.

Worked example: picking Count Occurrences from the Add menu opens the graph editor with a fresh Count Occurrences node connected to Terminal; since its own Selector field hasn't been filled in yet, the node's Output reads "Failed to evaluate — Template did not return a node result" until you configure it the same way described under Count Occurrences above.

Once you've built one, that same row swaps its three icons for four: edit (opens the iterator's own graph or code editor), remove, the AI suggestions atom, and a Type menu for switching between Graph and Code.

The same Iterators tab after building a Count Occurrences iterator, showing the Iterator (Graph) row with Edit, Remove, AI suggestions, and Type-menu icons in place of the earlier Add icon

There's also an AI suggestions button here — MorphMapper can detect repeating structures in your file on its own and propose an iterator for you, rather than you building one from scratch. See Working with plugins for how that detection works.