Change Location on Template of Positioned Box?

Hi, I am trying to change the x and y coordinates of a positioned box based on the value of a variable in my data set. Is this possible? Here are the 2 positions where I need the boxes to show: x = 2.125 in. y = 0.25 in., x = 2.1 in. y = 0.25 in.

Yes you can, you first need to convert the respective values to pixels and write the result to the offset-x and offset-y attributes of the respective box. See the screendump below.

Erik

// 1in = 96px
let x  = parseInt(record.fields.x) * 96
let y  = parseInt(record.fields.y) * 96
results.attr('offset-x', x).attr('offset-y', y)

@Erik What kind of script is that? Also, what is the “record.fields.x” and “record.fields.y”?

The record.fields.x and record.fields.y refer to the data fields holding dynamic values (see the Data Model panel in the screendump). Just wanted to show you could even use values from the data. Perhaps the following is more applicable in for your scenario. In this case I toggle the position when the ‘helloworld’ field is true:

let x  = parseInt('2.125in') * 96
let y  = parseInt('0.25in') * 96

if ( record.fields.helloworld === true )  {
	x  = parseInt('2.1in') * 96
} 

results.attr('offset-x', x).attr('offset-y', y)

It is a regular user script, where the selector targets the positioned box by ID. For this I’ve set the ID of the box via the Attributes panel.

Gotcha, thank you so much!