cancel
Showing results for 
Search instead for 
Did you mean: 

How can I create a custom formula that checks if a PC file exists? (CR10)

Former Member
0 Kudos

Post Author: lgayosso

CA Forum: Formula

Hello,

I need to create a formula that validates whether a PC file exists or not to display a message ('File Found' or 'File not found'). I created a custom formula that displays the appropriate message based on a report field composed of the FilePath + FileNameWithExtension that works correctly if the field includes a value or not (Basic Syntax below):

If {ctDocumentImages.ImgPath} <> "" Then Formula = "File Found"Else Formula = "File not found"End If

Now I want to validate that the {ctDocumentImages.ImgPath} value corresponds to an existing file; that is, I need to check that the file specified at {ctDocumentImages.ImgPath} location truly exists to determine that the file is actually 'found'. How can I accomplish this?

Any help is greatly appreciated,

Lucio

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Post Author: V361

CA Forum: Formula

Well, I only have the one connection, the connection itself, will search all sub directorys, do all your reports have the same .ext ie .rpt, if so, you can search for just those, and you can search the entire drive. (it will not be quick, but you can do that). Any chance of creating an indexed table that keeps track of where the reports are ? You could then report off that...

Former Member
0 Kudos

Post Author: lgayosso

CA Forum: Formula

V361@palmettogba.com:

( my file connection name was CrystalReports_Reports.File Name) I have generated a report, that shows all my rpt file names, size, last updated.... etc )

Go to database expert, create new connection, select file system data, your starting directory will be
genplex\E\JEMS51_Server\Imaging\Int\2007\..... you can then report on the file names found in that directory / subdirectory, etc... When creating the link you can select all files, or just *.rpt for example

Ok, so you define more than one connection on your report to be able to access the File System Object, right? The problem is that my reports are generic and meant for distribution for customers where no generic base folder will exist. The value of the starting directoy is then unknown, FilePath+Name then can be any value.

Lucio

Former Member
0 Kudos

Post Author: V361

CA Forum: Formula

( my file connection name was CrystalReports_Reports.File Name) I have generated a report, that shows all my rpt file names, size, last updated.... etc )

Go to database expert, create new connection, select file system data, your starting directory will be
genplex\E\JEMS51_Server\Imaging\Int\2007\..... you can then report on the file names found in that directory / subdirectory, etc... When creating the link you can select all files, or just *.rpt for example

Former Member
0 Kudos

Post Author: lgayosso

CA Forum: Formula

V361@palmettogba.com:

I have used this formula, and I get File Found when the filename matches.

if {CrystalReports_Reports.File Name} ="1800 Director Detail Report.rpt"then "File found" else "file not found"

Thanks for the reply. I tried building a formula using your example code hardcoding a valid FilePath+Name value but get the error "This field name is not known" with {CrystalReports_Reports.File Name}

This is how my formula looks:

if {CrystalReports_Reports.File Name} = "
Genplex\E\JEMS51_Server\Imaging\Int\2007\Case 04T0101011\20061204161207007.PDF"then "File found" else "File not found"

Is {CrystalReports_Reports.File Name} a Crystal Report's formula statement? How did you get such field?

Thanks again,Lucio

Former Member
0 Kudos

Post Author: V361

CA Forum: Formula

I have used this formula, and I get File Found when the filename matches.

if {CrystalReports_Reports.File Name} ="1800 Director Detail Report.rpt"then "File found" else "file not found"