I wanted to put an if condition in RDLC Reports to check a textbox value before placing a value in it but i am not getting the result desired
My code as follows:
=iif(ReportItems!CustAddr611.Value<>"",Code.GetData(6,1),Code.GetData(54,1) & " " & Code.GetData(55,1))
But it gives me an error display #Error when i run the report in NAV.
Also how can i add multiple report items in the conditional statement. VS tells me this error
Severity Code Description Project File Line
Error The Value expression for the textrun ‘CustAddr711.Paragraphs[0].TextRuns[0]’ refers to more than one report item. An expression in a page header or footer can refer to only one report item.
Often when referring directly to Report items you can get in a situation, where the ReportItem is out of scope, specifically if you move your elements around.
Your value might be out of scope or not set at all, I suggest that you try and put it in a variable in the Report Code.
Shared CustAddr611 as String
Public Function SetCustAddr611(Value as String) As String
CustAddr611 = Value
Return CustAddr611
End Function
Public Function GetCustAddr611 As String
Return CustAddr611
End Function
In your report items you use SetCustAddr611() when inserting it in the report and GetCustAddr611 in your iif
Related
I am working on peace of code where, rendering a report using ReportExecutionService.Render() method. I have passed following parameters to this method;
string format = "EXCELOPENXML";
string devInfo = #"False";
Report contains one column with hyperlink, but after rendering the report with Render method, output file is missing that hyperlink. If I export same report from report viewer to excel, resulting excel has the hyperlink on that column.
What can be the possible issue for missing hyperlink? Do i need to specify any particular format (i tried same thing with HTML, PDF formats as well but no luck)? Is there any workarround to get the hyperlink into the rendered report using ReportExecutionService.Render()?
The hyperlink to my SSRS report correctly renders parameters passed in on the URL query string. But the report does not render unless the View Report button is clicked. Other reports render as expected so I suspect something is wrong with the URL of the problem report:
http://reportserver/ReportServer/Pages/ReportViewer.aspx?%2fSales+Mgr+Reports%2fCustomer+Product+Variance+with+Net+Margin+Report&rs:Format=HTML4.0&rs:Command=Render&ReportType=PD&SortType=P&CurBeginDate=04/15/2013&CurEndDate=04/15/2014&CusCode=XXXXXXXXXX
That URL correctly fills the reports required parameters:
Why does this report fail to render even though I've included the command rs:Command=Render?
Thanks in advance.
Nevermind...I figured it out. Someone else might benefit though...
Blank parameters cannot be omitted from the query string. The two blank parameter boxes (Product Desc and Product ID) must be passed in with no value in order to make the render command work. It appears this is necessary even though those parameters are not required to run the report.
So the working query string has two (blank) parameters added on the end and looks like this:
http://reportserver/ReportServer/Pages/ReportViewer.aspx?%2fSales+Mgr+Reports%2fCustomer+Product+Variance+with+Net+Margin+Report&rs:Command=Render&rs:Format=HTML4.0&ReportType=PD&SortType=P&CurBeginDate=04/15/2013&CurEndDate=04/15/2014&CusCode=XXXXXXXXXX&ProdDesc=&ProdID=
I am using ASP.NET VB.NET, CSV File upload and FileHelpers, ASP.NET control is File Upload
Code to read CSV File
Using sr As New StreamReader(FileUpload1.PostedFile.InputStream)
Dim engine As New FileHelperEngine(GetType([MyClass]))
For Each entry As [MyClass] In engine.ReadStream(sr)
Next
End Using
FileHelpers
<DelimitedRecord(",")> _
<IgnoreFirst(1)> _
<IgnoreEmptyLines> _
Class [MyClass]
<FieldTrim(TrimMode.Both)> _
Public Prop1 As String
<FieldTrim(TrimMode.Both)> _
Public Prop2 As String
End Class
Question
There is some comma in data and due to that It is crashing.
VB.net provides exactly what you are looking for in Microsoft.VisualBasic.FileIO. You can use it in C# however, as shown below:
TextFieldParser parser = new TextFieldParser(pFileName);
parser.SetDelimiters(",");
parser.TextFieldType = FieldType.Delimited;
while (!parser.EndOfData)
{
string current = parser.ReadFields();
}
Edit
Just noticed you are using VB - basic premise remains the same, but don't know enough about VB.net to rewrite it. It will work though, as I had the exact same problem and it fixed it.
If your CSV looks like:
value1,value2,valu,e3
it always will be 4 columns not 3
But if CSV looks like:
value1,value2,"valu,e3"
I recomended use regexp split like:
var result = Regex.Split(csvline, ",(?=(?:[^']*'[^']*')*[^']*$)");
In this case,the file has errors and it's pretty much impossible to know what's wrong with an individual line except to say "there are too many fields when split by comma". There is no sane way your code can fix this error, you have to throw it back to the user who is uploading the broken file.
You can set the FileHelper's ErrorMode setting to SaveAndContinue (see here) so that it doesn't throw on error, and after your loop check the Errors property and if it's not empty, report the problem to the user, listing out each ErrorInfo in the Errors collection.
I'm rendering server reports (remote processing mode) through the ReportViewer control, but I also need to save the list of parameters each report has. The ReportViewer automatically generate the parameter-prompts for each report it's rendering, so I'm wondering if there's an event or properties that could allow me to access these parameter-prompts to obtain the name and number of parameters of the report?
You can do it via call to "SetParameters" method. Here's a sample code (VB.NET):
Dim aParamList As New Generic.List(Of ReportParameter)
aParamList.Add(New ReportParameter("ParamName1", "Parameter Value 1"))
aParamList.Add(New ReportParameter("ParamName2", "Parameter Value 2"))
ReportViewer1.ServerReport.SetParameters(aParamList)
If you don't know parameter names, to get them from the report you can use "GetParameters" method:
For Each oParamInfo In ReportViewer1.ServerReport.GetParameters
'oParamInfo.Name would hold parameter name
Next
I'm writing an applescript to automate some tedious work in Aperture, and I'm having a hell of a time understanding some of the peculiarities of the language. In particular, I'm having a really difficult time dealing with collections (lists and elements). I'm stumped by object specifiers that include collections and applying commands to elements in a collection. Moreover, I'm confused by strange differences in object specifiers that seem to behave differently when referring to object elements by their class within a class versus, well, let me show you.
Here's the beginning of a script.
prop Movies : {}
tell Application "Aperture"
set Movies to every image version whose name of every keywords contains "Movie"
end tell
length of Movies -- result => 601
The application object in Aperture contains an elements collection of image versions. image version objects contain an elements collection of keywords. keywords are objects/lists with a name and id property.
So the global script property Movies now contains all of the image version objects in my Aperture library that are actually videos. Now, when I try to do this:
repeat with movie in Movies
log ("Movie name is '" & name of movie & "'.")
log (" the class of this object is '" & class of movie & "'.")
end
the output, as expected, is:
Movie name is 'MOV03510.MPG'.
the class of this object is 'image version'.
Movie name is 'MOV00945'.
the class of this object is 'image version'.
Movie name is 'MOV03228.MPG'.
the class of this object is 'image version'.
Movie name is 'MOV02448'.
the class of this object is 'image version'.
...
However, I'm stuck with how to access an elements collection within those image versions. When I do this:
repeat with movie in Movies
log ("Movie name is '" & name of movie & "'.")
log (" the class of this object is '" & class of movie & "'.")
set kwnamelist to name of every keyword in movie
if kwnamelist contains "Movie"
log (" Yes, '" & name of movie & "' is indeed a video.")
end if
end
gives me
find_videos.applescript:1089:1096: script error: Expected class name but found identifier. (-2741)
The error, to me, sounds like applescript is confused by the object specifier name of every keyword in movie. BUT, the reason I'm so confused about this is that if I write this code:
tell Application "Aperture"
repeat with imageind from 1 to 1000
set img to item imageind of image versions
tell me to log ("Image name is '" & name of img & "'.")
tell me to log (" the class of this object is '" & class of img & "'.")
set kwnamelist to name of every keyword in img
if kwnamelist contains "Movie"
tell me to log (" '" & name of img & "' is actually a video!")
end if
end
end tell
then I get the expected output:
...
Image name is 'DSC_4650'.
the class of this object is 'image version'.
Image name is '104-0487_IMG'.
the class of this object is 'image version'.
Image name is 'MOV02978.MPG'.
the class of this object is 'image version'.
'MOV02978.MPG' is actually a video!
Image name is '108-0833_IMG'.
the class of this object is 'image version'.
...
Can anyone tell me what's wrong with my object specifier? Why is it that I can essentially apply get name to every keyword in img when the image version is in one context, but I can't in a different context? Is there something I'm missing here? Is it that the keyword class is internal to the Aperture application object? How would I specify something like application::keyword if that's the case?
UPDATE:
I've solved this particular problem, but I'd really appreciate it if someone could explain exactly why this solves it. I did this:
tell Application "Aperture"
repeat with movie in Movies
tell me to log ("Movie name is '" & name of movie & "'.")
tell me to log (" the class of this object is '" & class of movie & "'.")
set kwnamelist to name of every keyword in movie
if kwnamelist contains "Movie"
tell me to log (" Yes, '" & name of movie & "' is indeed a video.")
end if
end
end tell
gives the expected output:
...
Movie name is 'IMG_0359'.
the class of this object is 'image version'.
Yes, 'IMG_0359' is indeed a video.
Movie name is 'MOV02921.MPG'.
the class of this object is 'image version'.
Yes, 'MOV02921.MPG' is indeed a video.
Movie name is 'MOV02249'.
the class of this object is 'image version'.
Yes, 'MOV02249' is indeed a video.
...
It seems like there's a very peculiar scope issue at work here. Could someone explain to me how keyword objects are in scope in this new version, but out of scope in the previous version where we weren't in a tell block? I thought that tell blocks were just for directing commands without direct parameters? Do they determine type scope as well? Or is there a command hidden somewhere here in the construction/execution of the object specifier that depends on getting sent to the Application "Aperture" object?
If I understand the core of your question correctly - because you have solved the practical part, screwy dereferencing, which is a bit of an old chestnut for applescripters - you must only use terminology inside the relevant tell blocks, so if your application (Aperture) supplies the terminology "keyword", you can't refer to "keyword" unless you are inside a tell application "Aperture" block.
OR if for some reason you want to use terminology from a given app without using a tell block, you can wrap your code like this:
using terms from application "Aperture"
-- blah blah about 'keyword' and other Aperture terminology
end using terms from
Applescript is rather funny like this unfortunately and often times it's hit or miss. In this case repeat with item in list, item is a reference to the contents, not the contents itself. Often times AppleScript will dereference this for you, but not always. Typically I always use the repeat with x from 1 to count method to avoid this problem.
About scripting Aperture keywords
Keyword scripting in Aperture 3 is quite unintuitive. Here's what Ive learned:
A keyword's id is a string with the path from the keyword name up to its top-level parent, with each parent's name preceded by a tab.
The value of the parents property is just the id without the name and, if the keyword is not at the top-level, the tab following the name.
Keywords don't compare equal even if their values are the same; in fact, keyword 1 of animage != keyword 1 of anImage.
An image may have multiple keywords with the same name if they have different parents. However, the name will only appear once wherever the image's metadata is displayed.
The way to add a keyword to anImage with name aName and parents theParents is tell anImage to make new keyword with properties {name:aName, parents:theParents, id:aName&tab&theParents}
See my entry here for a fuller explanation plus add and remove handlers.