Restrictions of job.getVariableAsString

Post Reply
thorsten
Newbie
Posts: 14
Joined: Thu Apr 14, 2022 12:08 pm

Restrictions of job.getVariableAsString

Post 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?
Regards,
Thorsten
jan_suhr
Advanced member
Posts: 726
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Restrictions of job.getVariableAsString

Post by jan_suhr »

Do you have await before job.getVariableAsString ?


https://cdn.enfocus.com/manuals/Develop ... binfo.html
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
thorsten
Newbie
Posts: 14
Joined: Thu Apr 14, 2022 12:08 pm

Re: Restrictions of job.getVariableAsString

Post 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".
Regards,
Thorsten
freddyp
Advanced member
Posts: 1207
Joined: Thu Feb 09, 2012 3:53 pm

Re: Restrictions of job.getVariableAsString

Post 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.
Post Reply