Categories > OpenTBS with DOCX >

Display "not available" text when field is empty (using MergeBlock)

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: w5m
Date: 2016-09-22
Time: 13:09

Display "not available" text when field is empty (using MergeBlock)

Hi there,

I'm using MergeBlock and passing a SQL query to it. In my docx template, if any fields returned by the SQL query are blank (i.e. empty strings) is there an easy way to show the text "not available" rather than the empty string?

I realise I can build this into the query itself, but I wondered if there was a means to do it via OpenTBS itself.

Many thanks.
By: Skrol29
Date: 2016-09-27
Time: 09:42

Re: Display "not available" text when field is empty (using MergeBlock)

By: w5m
Date: 2016-09-29
Time: 12:59

Re: Display "not available" text when field is empty (using MergeBlock)

Superb - I hadn't spotted that option. Many thanks.
By: w5m
Date: 2016-09-29
Time: 17:34

Re: Display "not available" text when field is empty (using MergeBlock)

I've gone through my template adding ";ifempty='NA'" immediately after the field name and before the closing square bracket, for each field.

When I run the script, I get the following error message for just 10 of the 100 or so fields in the template and I can't see what these 10 fields have in common.
TinyButStrong Error in field [Sample.condSizeThis message can be cancelled using parameter 'noerr'.

If I remove the ";ifempty='NA'" suffix from a field name in the error message, the error goes away.

Do you have any suggestions for how to debug this issue?
By: Skrol29
Date: 2016-10-04
Time: 13:04

Re: Display "not available" text when field is empty (using MergeBlock)

Hi,

Check the inner HTML of this error message.
I think your [Sample.condSize] field has some hidden formatting that produces a break in the TBS tag.
If it's true, the inner HTML of error message should contain some XML coming from the template.

In order to fix this, simply select the TBS tag, cut it, and then « paste without formating ».