KM variable feeds Javascript

Well I tried, ChatGPT, Bard, Copilot , KM Forum.
So just going to lay it out here.

In KM: I have a KM script it simply copies an alphanumeric field in a spreadsheet into a variable and then can output that to the screen for display - so I know that is working.

In Javascript: I have a script that can read in a bunch of data from an XLSX spreadsheet, record by record. No problem there so far.

What I am trying to make happen is that, once the KM script creates an alphanumeric variable 'InvoiceNumber', I want to have it available for use within the Javascript file.

Once processed (where I am matching the InvoiceNumber to a record and extracting the date from the same record), I want to pass a new variable called 'InvoiceDate' back to KM.

So I am basically looking for the setup to pass variables:

  • From KM to JS
  • From JS back to KM

Any direction would be appreciated.

action:Execute a JavaScript For Automation [Keyboard Maestro Wiki]

See the section on using Keyboard Maestro variables.

Reading from JS:

  • Choose Modern syntax in the chevron to the left of the action and refer to variable names prepending the prefix kmvar

Writing from JS to Keyboard Maestro:

  • See Application("Keyboard Maestro Engine").setvariable

(Large Language Models are a waste of time for this kind of thing. Not enough online material on Keyboard Maestro for them to build up their distributional vector slurry to any level of relevance. The output aims to sound plausible, but is based on no model whatsoever of the actual issues. Also burns a lot of server energy pointlessly. Investor-driven hype is distracting us there.)