Skip to Content
0

Preview Mode With Report Based on List<>

Nov 29, 2017 at 08:47 PM

52

avatar image

I am looking at using a List<> as a source for some of the data on my reports. I have it working nicely, but there is one issue. I can't see the List<> data on the preview tab - I have to run the report with my app to see how it looks. I understand why this occurs (my app can't provide data to a report running inside visual studio).

I am using a List<> with one item to get some shared data. I stick properties from the object into shared variables in a subreport:

shared stringvar thing := {my_object_name.thing};

I then use the shared variables elsewhere on the report. This works fine in the app, but when I go to preview mode, all my shared variables are blank.

My question is: is there any way to provide default data for preview mode so I can at least see something? I tried this:

if (IsNull({my_object_name.thing}) then 
	thing := "Default Value"; 

It didn't work. Anything I can do about this?


If necessary, my workaround will be to use parameters to set the shared data values, instead of binding the app data to the report. However, one of the shared data items is an image (as a byte array), which I don't think I can display with parameters and formulas, so I will have to bind something either way.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Dell Stinnett-Christy Dec 04, 2017 at 10:53 PM
0

Crystal may see the values from the list that isn't there as empty strings instead of as nulls. So, you might try something like this for setting the variable values:

shared stringvar thing;
if (IsNull({my_object_name.thing}) or ({my_object_name.thing}) = '' then 
	thing := "Default Value"
else
	thing := {my_object_name.thing}

-Dell

Share
10 |10000 characters needed characters left characters exceeded
Don Williams
Dec 01, 2017 at 05:06 PM
0

Hi Ray,

What SDK are you using?

Windows or WEB app?

Don

Share
10 |10000 characters needed characters left characters exceeded
Ray Novak Dec 04, 2017 at 10:43 PM
0

Hi Don - I missed your reply - I thought I would get an email since I followed this thread

Anyway, I am using the Windows SDK in a C# ASP.NET project, exporting directly to pdf (no report viewer)

Share
10 |10000 characters needed characters left characters exceeded
Ray Novak Dec 04, 2017 at 11:30 PM
0

Thanx Dell - I tried your suggestion and got the results I was looking for. And then I found something else interesting. It worked with just the IsNull test, even though that didn't work for me originally. A little fooling around, and I figured out why. If I added any additional variable declarations before my 'if'; statement, like this:

// this one doesn't work
shared stringvar thing;
shared stringvar thing2;
if(IsNull...


the value of 'thing' was blank (or null). If I moved 'thing2' below the 'if', it worked fine, and I got the default value I wanted.

// this one works
shared stringvar thing;
if(IsNull...
shared stringvar thing2;
Share
10 |10000 characters needed characters left characters exceeded