Page 1 of 1

Restrictions of job.getVariableAsString

Posted: Wed Aug 12, 2026 2:37 pm
by thorsten
Hi there,

what exactly are the restrictions of this function in node.js script expressions?

Given is an XML structure like

Code: Select all

<Job>
  <Meta Key="key1" Value="value1"/>
  <Meta Key="key2" Value="value2"/>
  <Meta Key="key3" Value="value3"/>
</Job>
In legacy scripting

Code: Select all

job.getVariableAsString('[Metadata.Text:Path="//Meta[@Key=\'key2\']/@Value",Dataset="Job",Model="XML"]');
delivers "value2" as expected. Using Switch variables also works fine.

In node.js I get "The Variable Path is Incorrect".

It looks like referencing the attributes doesn't work in node.js.

Is it a bug oder a feature?

Re: Restrictions of job.getVariableAsString

Posted: Wed Aug 12, 2026 2:41 pm
by jan_suhr
Do you have await before job.getVariableAsString ?


https://cdn.enfocus.com/manuals/Develop ... binfo.html

Re: Restrictions of job.getVariableAsString

Posted: Thu Aug 13, 2026 7:59 am
by thorsten
Hi Jan,
jan_suhr wrote: ↑Wed Aug 12, 2026 2:41 pm Do you have await before job.getVariableAsString ?
yes, I did. I just wanted to keep it short here. Other queries are working and like I said: there is a result but it's always "The Variable Path is Incorrect".

Re: Restrictions of job.getVariableAsString

Posted: Thu Aug 13, 2026 1:29 pm
by freddyp
It would take too long to explain here but job.getVariableAsString in NodeJS is limited compared to the one in legacy. And one of the things that will not work is the use of a variable that extracts a piece of information from a dataset.

As an alternative the scripting API has an XmlDocument class: https://cdn.enfocus.com/manuals/Develop ... thods.html. There is sample code on that page you can reuse.

The fact that this is part of the scripting API means you can also use this in a script expression.