Crystal: Default value as fallback (from Database)

35 views Asked by At

We are planning to use CR2013 for creating invoices and other documents for our customers.
Report-Generation will be initiated by JAVA-Call.

In genral all documents have the same basic layout but for some of our customers we need special texts in the Footer of the document.

The idea was, to have 3 tables:

  • customer
  • invoice-data
  • custom-texts

All three tables could be reverenced and connected by customer_id.

Custom-Texts should now contain a row with customer_id = 0 which will act as a fallback if customer-specific texts are not provided.

Example:

Custom-Texts

ID    | customer_id | Footertext 1 | Footertext 2
- - - - - - - - - - - - - - - - - - - - - - - - -
0     | 0           | Defaulttext  | Defaulttext
1     | 44          | Special Text | Special Text    
2     | 78          | Special 2    | Special

So for customers with id 44 and 78 the special texts are taken, for all others the texts provided in id = 0.

Is this possible and how can we do?

1

There are 1 answers

3
Siva On

create a formula in footer and write below code. Below code assumes both Default Text and Special Text coming from databse

if customer_id=0
then Footertext 1
else Footertext 1

above code compares the id to 0 if yes returns default text and if no returs special text

follow the same process for Footer2 aswell.

Edit---------------------------------------

place a sub report in the footer.

in that sub report create a group with customer ID. and the place the below formula in detail section

Footertext 1

now just display detail in subreport and supress all other sections.