Print Page | Close Window

Accessing Boolean Group Conditions via API?

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=3477
Printed Date: 11 Apr 2025 at 4:41am


Topic: Accessing Boolean Group Conditions via API?
Posted By: epaga
Subject: Accessing Boolean Group Conditions via API?
Date Posted: 18 Jun 2008 at 11:52pm
Hi there,
I can access date group conditions via the API, but for some reason the same idea does not work for boolean group conditions (such as grouping on "change to yes" or "change to no", etc.).

Here's my code:

foreach( Group g in dataDefinition.Groups ) {
    if( g.Options is DateGroupOptions ) {
       Console.WriteLine("is date group! condition: "+
            (((DateGroupOptions)g.Options).DateCondition));
    } else if( g.Options is BooleanGroupOptions ) {
       Console.WriteLine("is boolean group! condition: "+
            (((BooleanGroupOptions)g.Options).BooleanCondition));
    }
}

I have a date-based group "by year" and another boolean-based group with "change to yes". But only the date group line is written to the console. Why? Is there some other way to work around this problem? I've even been thinking of workarounds like adding a group name field based on the boolean group to the report in order to get its formulaform in order to parse the formulaform in order to get the boolean condition. yeah, that seems crazy but if it's the only way to get the info?

Any thoughts would be most welcome, thanks.

BTW, if this isn't possible via the API, this might be an idea for a new chapter for your new book: "Things you CAN'T do with the API." ;)



Replies:
Posted By: BrianBischof
Date Posted: 24 Jun 2008 at 12:25am
Re your question, I would have to build a sample report to recreate this scenario and play around with it to figure out why it doesn't print. But my initial guess is that you need to do a ToString() on it, or a similar conversion to get it into printable format.

Re your suggestion for a new chapter on "Things you CAN'T do with the API", this would actually be a full book unto itself. What they really want you to do is upgrade to CR 2008 and once you do that, the API increases dramatically (the whole point of putting CR in .NET is for the up-sell anyway).

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: epaga
Date Posted: 24 Jun 2008 at 2:42am
Actually the ironic thing is I'm trying to do this (and the scenarios described in the other threads) with the CR2008 .NET API! ;)

As you can see in the code, the GroupOptions is not a BooleanGroupOptions, so a ToString doesn't help there. :-(


Posted By: BrianBischof
Date Posted: 24 Jun 2008 at 2:32pm

You're using CR 2008 .NET API? Bummer. I'm going to dig into this deep once I finish the other chapters in my book...

When you look at BooleanGroupOptions in debug mode, what do you see? Is there any value displayed? Is it an enumerated list you could use in a custom function that would return a string value?


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: epaga
Date Posted: 25 Jun 2008 at 1:29am
yeah i already tried all that. :-( oh, well...

thanks, though!



Print Page | Close Window