Scripting in Report Designer
So far I have been unable to bring in variables from the workflows into my C# script in report designer. My report is setup to take in variables through the "DataField" and this works well. Type in the name of the field into "DataField" and the correct value is displayed. I would like to use that same variable to run conditional statements with in the script. /customer/servlet/servlet.FileDownload?file=00P6000000elto3EAA This picture shows that the "DataField" contains the variable LineA. I would will to be able to use variable LIneA in the scripting tab but have not bee able to get the information into the script. Does anyone have any ideas how I can do this?
-
It is pretty straight forward. I think the issue most people have is thinking that the Picture control will dynamically read an image from a URI. It won't, rather you have to read the Image from the URI manually, then apply that image to the Picture objects Image property.
Code sample:public void Detail1_Format()
{
String imageFolder = "E:/Images/";
String imagePath = null;
if(rpt.Fields.Contains("IMAGENAME")){
String imageName = Convert.ToString(rpt.Fields["IMAGENAME"].Value);
imagePath = imageFolder + imageName;
if(System.IO.File.Exists(imagePath)){
System.Drawing.Image theImage = null;
theImage =System.Drawing.Image.FromFile(imagePath);
Picture thePic = rpt.Sections["Detail1"].Controls["Picture1"] as Picture;
thePic.Image = theImage;
}
}
}Hope that helps.
Jay
0 -
Thanks Jason,
I tried that code but it pukes and says compile error on line 21 =; expected..
any thoughts?
public void Detail1_Format()
{
String imageFolder = "D:/Data_Client/YourTown/SidewalkInspection_Images/";
String imagePath = null;
if(rpt.Fields.Contains("lblFileName"))
{
String imageName = Convert.ToString(rpt.Fields["lblFileName"].Value);
imagePath = imageFolder + imageName;
if(System.IO.File.Exists(imagePath))
{
System.Drawing.Image theImage = null;
theImage =System.Drawing.Image.FromFile(imagePath);
Picture thePic = rpt.Sections["Detail1"].Controls["Image1"] As Picture;
thePic.Image = theImage;
}
}
}0 -
C# as operator is case sensitive.
Change: Picture thePic = rpt.Sections["Detail1"].Controls["Image1"] As Picture;
To: Picture thePic = rpt.Sections["Detail1"].Controls["Image1"] as Picture;
0 -
Good Morning,
We have this script working in a similar fashion for a URL from a 3rd party that display's property photos. What I was wondering is if anyone has a script method that will work with code similar to Jason's here to handle 404 exceptions. For example if a user clicks on a parcel that does not have a current photograph of the property, the report throws an error due to the 404 or 500 return that the URL with the photo does not exist. I haven't been able to get the correct format to run to grab these type of exceptions, replace the photo to display and move on to url's that are valid. Any help would be appreciated.
Thanks!
Brian
0 -
The easiest way to work around these exceptions would be to use a try...catch block:
try
{
// Get the picture
}
catch (Exception ex)
{
// Do nothing, maybe show a placeholder image, or text ex.Message
}
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
5 Kommentare