Skip to main content
Known Participant
June 5, 2022
Question

Variables passed to docx should be accessible everywhere and repeatedly?

  • June 5, 2022
  • 1 reply
  • 507 views

Finding some strange behavior which I can't explain. I am not super facile with node.js but assume when a variable is passed, it is accessible anywhere and repeatedly. Please correct me if I am wrong.

 

On a page of the docx, I am calling a variable which doesn't return anything...

 

# example
On a scale of 0-100, the document’s sentiment score is: {{ sentiment }}

 

However, if I repeat it elsewhere it renders...

 

# test area at the bottom of the doc
Test section
sentiment: 98 <-- this is the {{ sentiment }} variable repeated

 

# here is a snippet of the sampleData passed to the doc

const sampleData = {
<snip>
"sentiment": sentiment,
</snip>
};

 

# and here is a console.log of the correct sampleData
INFO sampleData--> { sentiment: 98}

 

I thought it was related to upgrading to @adobe/pdfservices-node-sdk 2.2.2 but I rolled back to 2.2.0 and the behavior still exists. In previous months, calling variables was rock solid and I got exactly what I expected.

 

Thanks in advance.

 

 

This topic has been closed for replies.

1 reply

Joel Geraci
Community Expert
Community Expert
June 9, 2022

Are the fields within different contexts within the Word document like one is at the document level, one is in a table or conditional section etc? Can you share the Word file + the JSON?

Vince5E52Author
Known Participant
June 9, 2022

That's the puzzling part; it's a simple variable taken from a dbase further upstream and passed in to a single field. 

 

I will try to rip out the other code (I have ~10 variables used correctly), slim down and post.  

Vince5E52Author
Known Participant
June 10, 2022

Oddly, if I repeat the line, one right after the other, the first does not work but the second does.  For now as a shim, I'm 'whiting out' the first line.  Back soon.