Expand my Community achievements bar.

saveXML() wont work for text object

Avatar

Level 1

Hi all,

I am pretty new with LiveCycle and I have faced my first problem on the coding side.

I have attached two screenshots where you can see what I am trying to do.

On first sreenshot I am using the code  snipplet

xfa.form.FormElement.Subform.TextField1.rawValue = xfa.form.FormElement.Subform.TextField2.saveXML('pretty');

and trying to write a xml output in textfield1. It works.
Second one is trying to do the same but this time a text object is used instead of a textfield.
xfa.form.FormElement.Subform.TextField1.rawValue = xfa.form.FormElement.Subform.Text1.saveXML('pretty');
The code delivers an empty xml. Should I call some method to initialise the text object on some level, so I can get an xml output for this object?

Thanks in advance,

Koray

1.PNG2.png

6 Replies

Avatar

Level 10

Hi Koray,

The text object is static and does not take part in XML import/export/save.

If you want it to be part of the XML data processing, you could change it to a textfield object and then in the Object > Value palette, set its value and (more importantly) set its access to Read Only.

Also in the Object > Binding palette, you should make sure that the binding is set to Name (or Normal, depending on which version of LC Designer you are using). A global binding will also work, anything other than None.

Hope that helps,

Niall

Avatar

Former Community Member

Koray

Maybe you shoudl describe what you are trying to do ...most people do not work with saveXML .....there might be a better/easier way.

Paul

Avatar

Level 1

Niall, Paul thanks for the prompt answer!

@Niall: Your solution works fine but since I will have a long and formatted text, that I want to personalize I can't use it.

@Paul: You are right let me explain my case. I have some parameters delivered to my pdf file and I want to personalize a paragraph that I have with these parameters. Some of these parameters are boolean flags and decide if some part of text is shown or not. On initialise phase I ran the code below. I was succesful with it. The code was looking like this:

xfa.form.FormElement.Subform.Text1.value.exData.value = xfa.form.FormElement.Subform.Text1.value.exData.value.replace('<Your Name>', 'James Bond');

If I try something like this on a PDF file locally it works fine. But I am using Adobe Offline Forms for SAP BPM. So SAP NEtweaver Portal generates a PDF file from a XDP and sends it to the end user. On this PDF output string replace also works fine but this time formatting of the file is messy. There are many linebreaks in it. So I thought I use savexml before making my change (using replace) and then I can use loadxml with the new string and don't harm the formatting of the file. It would be looking like this:

var xml_output = fa.form.FormElement.Subform.Text1.saveXML();

xml_output = xm_output.replace('<Your Name>', 'James Bond');

xfa.form.FormElement.Subform.Text1.loadXML(xml_output);

Thanks again,

Koray

Avatar

Former Community Member

You are making this much more difficult that it needs to be. There is a concept of a floating field which you add (from theinsert menu) into a block of text. This is a field that you can bind to input data and it will be replaced with the data from the inbound XML. Once that is done it is turned into text and the text block os reflowed.

As far as hidding and sowing sections you will have to code against that. You can look at values in the data dom (the area  where all of the data is stored) or many people will bind the da a to hidden fields and interrogate the hidden field (easier to code).

Hope that helps

Paul

Avatar

Level 1

Yes I was doing exactly that =) I was not aware of the floating field object. I could implement something fitting my needs in 10 minutes. For both hiding showing/place holder needs I have used floating objects.

Thanks for the prompt help! Really appreciated.

Avatar

Former Community Member

Glad it is working for you and that we could help.

Paul