Populating floating field with a variable

marcink-lwR9iu 03-09-2018

I have a floating field called: FF_Name. Can I use a varialble with the same name to populate that field? Or do I have to use FF_Name.rawValue?

I this: I have a global variable called: myVar. Somewhere down in my hierarchy I have a floating field called: myVar. My expectation was, the floating field will be changed to the value of myVar. But that didn't work. I had to rename the floating field (myFloatingField) and in the initialize event i had to:

this.myFloatingField.value = myVar;

That worked, but i'd rather avoid using code for this thing

Accepted Solutions (1)

Accepted Solutions (1)

BR001
MVP
03-09-2018

Hi,

There is another option, if you are willing to edit the XML Source of your form.

When you insert a floating field Designer will insert a bit of xHTML in your text object that looks something like;

<span xfa:embedType="uri" xfa:embedMode="raw" xfa:embed="#floatingField016841"/>

The "floatingField016841" bit is a reference to the hidden field containing the value to insert.

You can also have xHTML that references a SOM expression, so in your case assuming your form is called form1

<span xfa:embedType="som" xfa:embedMode="raw" xfa:embed="form1.myVar"/

Will insert your global variable.

Saves the having the hidden field

Bruce

Answers (3)

Answers (3)

BR001
MVP
04-09-2018

Hi Marcin,

It scared me for a while, but sometimes it was the only so did get comfortable with it.

There is a macro facility within Designer, so you could get around it that way.

Regards

Bruce

marcink-lwR9iu 04-09-2018

Hey Bruce

Yes, that answers my question - but I was hoping on doing it without having to change the xml.

We work in a bigger team, and not all people are having a coding background and are kind of, how to put it, reluctant on editing the xml sources...

Thanks!

Marcin

MinusZero 03-09-2018

Hi,

I wrote a bit here about Global Variables: How to compare global variable value to TextField value

I would expect you might be able to use the same name, but you will need to specifically reference it.

this.resolveNode("myVar.rawValue") = global.myVar; //global is the name of your script object.