How i can make parentheses before a field that will be printed if it exists

Hi I would like to make parentheses before a field that will be printed if it exists :

something like that : (service.gruppe.rec_name)
Here is the code :

          <table:table-cell table:style-name="Table3.MS" office:value-type="string">
             <text:p text:style-name="P5"><text:placeholder text:placeholder-type="text">&lt;service.rang&gt;</text:placeholder><text:placeholder text:placeholder-type="text">&lt;(service.gruppe.rec_name) if service.gruppe else ''&gt;</text:placeholder></text:p>
          </table:table-cell>

Although a parenthesis is placed before service.gruppe.rec_name and after service.gruppe.rec_name but no parenthesis appears , just the service.gruppe.rec_name displayed. so please how i can correctly do that , exactly How i can make the parenthesis appears only if the field exists!

The text of the placeholder is Python code, so parenthesis there is to group Python statements.
If you want to show you must make Python format a string which contains parenthesis like:

'(%s)' % service.gruppe.rec_name if service.gruppe.rec_name else ''
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.