Expand my Community achievements bar.

SOLVED

Populating floating field with a variable

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Level 10

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

View solution in original post

4 Replies

Avatar

Level 7

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.

Avatar

Correct answer by
Level 10

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

Avatar

Level 2

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

Avatar

Level 10

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