Expand my Community achievements bar.

How to bind to a field in the form but only show part of the field

Avatar

Former Community Member

Hi,

Basically i want to bind to a field in the XML that its 13 characters long but i only want to show the last 4 characters.

Anyone knows how to configure the data binding so it only displays a portion of the chain?

Capture.JPG

12 Replies

Avatar

Level 7

I'm not sure if it would work for you, but you could try using a picture clause. Look at the XFA specification (Ch. 26) for some examples.

Avatar

Level 10

Hi,

I think you might end up having to use the calculate event to set the value (using $data.resolveNode(...).value).

Are people able to update the value or is it read only?

Regards

Bruce

Avatar

Former Community Member

Hi Bruce,

Its read only. Im not very familiar with LiveCycle so I trying to figure out if the bind value read is as follows: 202356250123

I want to show the value in 2 fields; 1 showing the first 9 characters and second one showing the last 4 so the label appears as follows:

Thanks and kind regards

Ario

Avatar

Level 10

Hi Ario,

If you were to make the SFC field hidden, then in the calculate event of the first field put;

SFC.rawValue.substr(0,9)

and the second field put;

SFC.rawValue.substr(-4)

Regards

Bruce


Avatar

Former Community Member

Thanks for the Quick Response Bruce

I have created the following event and changed the field to invisible but the output its blank. Maybe im in the wrong calculate event or the script its incorrect?

Thanks and kind regards

Avatar

Level 10

You should put the code in the calculate event of the field with the 9 characters and the other in the field with 4 characters.  The code I gave was JavaScript not FormCalc. 

Can you post a link to your form so we see whats going on.

Regards

Bruce

Avatar

Former Community Member

Hi ,

See attached form, basically the 2 fields are binding to the same data but in one field im trying to show the first 9 characters and in the second field we are trying to see the last 4 characters

The barcode itself its just going to present a 2D datamatrix code of the binding field.

Thanks and kind regards

Ario

Avatar

Level 10

Hi Ario,

There's nothing attached, can you try loading your form onto Google Docs (or similar) and adding a link here.

The 9 and 4 character fields should not be bound to anything, they will get there value from the calculate event.

Regards

Bruce

Avatar

Former Community Member

Hi Bruce

I have uploaded the file in google docs as public so you should be able to access it now.

https://drive.google.com/file/d/0B7x-xbDNuRA1Tm5GNFRubEtVY1k/edit?usp=sharing

So both fields are binding to the same field but in the first one I want to show the start of the chain (9 characters) and the second field I want to show the last 4 characters

Sorry for such basic questions, im just starting to get familiar with this software package

Thanks and kind regards

Ario

Avatar

Level 10

Hi Ario,

Try removing the binding and add the following in the calculate event, not sure which one has the 9 characters and which the 4.

But for the 9 characters;

$data.resolveNode('PrintContent.sfcPrintingData.sfc').value.substr(0,9)


and for the 4 characters


$data.resolveNode('PrintContent.sfcPrintingData.sfc').value.substr(-4)


Regards


Bruce

Avatar

Former Community Member

Hey Bruce, that worked very well. Changed slightly bit the code.

Avatar

Former Community Member

Hey Bruce, that worked very well. Changed slightly bit the code.

Thank you very much for the help

Ario