Variable is 0

Hello, in LibreOffice (6.0.5.2 x64 Build ID: 54c8cbb85f300ac59db32fe8a675ff7683cd5a16) Writer I set variable (in menu Insert → click on Insert fields = or press CTRL+F2 → go to Variables card → go to Set variable → choose one or in Name write its name → then in the Value field write its value). Then in page header I show the same variable. Despite the variable has been set, it is shown as 0.

Five years ago there was a similar question 14092 in LO 4.0.0.3, three years ago in LO 5.2.0.4 it still wasn’t changed, today in 6.0.5.2 it is still a bug…

Bug fdo#60886 hasn’t been resolved.

Well, the steps you describe are not detailed enough.

The feature works as expected. Moreover, I have used this feature throughout my admin-times, when I had built a number of templates for my employer that followed quite complicated national standard, that was only possible using “set in body/show in header/footer” fields; and the templates are used since 2007 till today, with a short interruption caused by tdf#60886 you cited, which was successfully resolved.

Right now, I have created a simple test to show that (and how) it works, using Version: 6.1.0.1 (x64)
Build ID: 378e26bd4f22a135cef5fa17afd5d4171d8da21a
CPU threads: 4; OS: Windows 10.0; UI render: default;
Locale: ru-RU (ru_RU); Calc: CL.

In it, I add two Set Variable fields (for Var1 set to 1, and Var2 set to 2) in the first paragraph of page body, in the first and third position; one such field (VarInFrame set to 4) in a text frame anchored to the first paragraph; and one such field in the third paragraph (for Var3 set to 3). I put the four corresponding Show Variable fields to the header; and as you can see (I hope, unless there’s a bug in some version you happen to have), the three fields that are in or linked to the first paragraph do show the set values, while the one in the later paragraph does not (but it will show the value on following pages).

It is expected and OK; the header takes the data from the first paragraph. It would produce strange and unexpected results if it did otherwise, e.g. for pages with multiple Set Variable fields, where additionally the variable would already have a value set on some previous page. So, if you need to show the variable value in the header, it must be set in the very beginning.

By the way, setting the variable in a text frame allows for creating non-printing frames (which may be set in the frame properties) which allows to use visible field definitions, while not distorting the page text layout (so basically having WYSIWYG). In the frame, you may put multiple paragraphs with variable definitions, and all their values would be visible in header, as long as the frame itself is anchored to the first paragraph.

EDIT 2018-07-17: great you have posted the relevant info! (Which should be the first thing to do anyway.) This is yet another case of using the feature properly, and has nothing to do with tdf#60886.

The problem there is the format of the field. By default, the Set Variable fields have numeric format, so any non-numeric value (like the text “Author”) end up as 0. You need to set variables as text to be able to show them as text.

Go to page 17 of 38 (Page 13), and replace the existing Set Variable field with a new one (you cannot change the field type after creation as far as I know); set the field Format to Text:

Then re-create the Show Variable field on page 18 of 38 (Page 14), which will get the correct type right away.

See page 14 in footer, ie. 18 in the whole document, I see “0”:

my.odt

my.jpg

The name of the variable is “Autor”. Sorry for my English.

Please move this to the question (edit it), since this is not an answer. Answers should answer original questions.