Post

2 followers Follow
0
Avatar

Conditional statements for report sections

Hi everyone!

I'm trying to do some conditional reporting, and I need some assistance.  I have the following code:

Security Requirements

 $repeatRequirements where Package = ‘Security Requirements’ $DeleteEmptyLine

$Name

$Description $DeleteEmptyLine

 $endRepeatRequirements

What I want to be able to do is to eliminate the entire selection under either of two conditions:  1) when there is no Security Requirements package or 2) when there are either no requirements or there are no requirements with a valid description (or some other specific attribute) in the Security Requirements package.

I can very easily rename the Security Requirements package (e.g. to "Security Requirments - N/A").  That eliminates everything except for the heading.  I can't include the heading in the existing loop, because then it would repeat after each requirement.

I don't have a lot of experience using $if or $exclude.  I tried:

$if Package = 'Security Requirments' and Requirements exist

Security Requirments

$repeat...

$endif

but that elimnated the whole section, even whent the package and the requirements exist.

Anyone got any thoughts or suggestions?

(N.B.  I am going on vacation for a couple of weeks, so I probably won't respond until I return, but I wanted to put this out there to tweak your interest.)

Tom Tomasovic Answered

Please sign in to leave a comment.

2 comments

0
Avatar

Hi Tom,

I don't think $if will be able to do what you need.  $if has the capability to check the value of a particular property (e.g. name or priority), and it can check the existence of items in the context of an owning item, (e.g. checking if Notes exist inside a $repeatUseCases, or requirements exist inside $repeatPacakges).  It can't however check for existence of items outside the owning context nor can you check for the existence of a pariticular kind of element (e.g. can't say $if Requirements Exist where priority = 1).

What I would suggest is to use $table instead of $repeat and include your header as the first row of the table.  What happens is when CaseComplete determines that there are no elements that fit the criteria to fill the table, it removes the table from the report. It does this to avoid a lot of empty tables in the report.  So, you could do something like this:

+----------------

| SECURITY REQUIREMENTS

+----------------

| $tableRequirements where  Package = ‘Security Requirements’

| $Name

| $Description

| ...

+-----------------

The dashes represetent the rows of the table in Word.  Note that you can turn off borders so that it doesn't look like a table if you don't want it to.  Hope this workaround can work for you.  Let me know if you have any questions.

Doug

Doug Earl 0 votes
Comment actions Permalink
0
Avatar

... or you could bracket your code with:

$repeatPackages where [Name like ‘Security Requirements’]

... everything else ...

$endrepeatPackages

This will suppress everything if there is no package named "Security Requirements".

Sonova 0 votes
Comment actions Permalink