Hi Imitiaz,
You need to have IF THEN ELSE logic in place for all template objects. However, for that you need to come up with all possible combinations or some pattern which can distinguish among templates.
Are templates only related to CASE_IDs or other dimensions as well?
Are you not storing template values at database level? If yes, are they stored in same table or different tables? If different tables then is the correct cardinality set?
Best way will be to handle it at table level itself i.e. storing a Yes or No for template column as per the CASE_ID getting stored.
Regards,
Yuvraj