Page 1 of 1
Find a row in a DataTable using expression
Posted: Tue Aug 13, 2013 12:23 pm
by Fuglesteg
Hello,
I am trying to initiate a user requested variable by an expression. I need to find the row Concepts.Name = "TCId" and return a value from that row in the column Concepts.Description. Could you please help me with this? The Concept.Description column contains RTF text. Is it possible to convert this to string?
Thank you,
Anders
Re: Find a row in a DataTable using expression
Posted: Fri Aug 16, 2013 9:12 am
by Fuglesteg
I have succeeded in initiating a variable by entering a rendering event in the Report.

- RenderingEventOverview.png (14.4 KiB) Viewed 2397 times
The code:
System.Windows.Forms.RichTextBox rtBox = new System.Windows.Forms.RichTextBox();
string temp="";
Concepts.First();
while(!Concepts.IsEof)
{
if (Concepts.Name=="StTeamcenter ID")
temp=Concepts.Description;
Concepts.Next();
}
// Use the RichTextBox to convert the RTF code to plain text.
rtBox.Rtf = temp;
strTCDoc = rtBox.Text;
The variables show correctly in the report, but if I allow the user to change the values of the attribute, the parameter input field is not populated with the values from the DataTable. This step has to be done for all required variables.
1. Would you say this is an OK approach or could this be done more effectively?
2. Would it be possible to achieve the same with an expression? E.g. By creating a function that can be called by an "init by" expression script.
Thank you
Re: Find a row in a DataTable using expression
Posted: Fri Aug 16, 2013 2:54 pm
by HighAley
Hello.
Could you describe what do you want to get?
Please, describe what behaviour should report have and we will propose you better solution.
Could you also send us your report template with sample data for analysis?
Thank you.
Re: Find a row in a DataTable using expression
Posted: Mon Aug 19, 2013 7:37 am
by Fuglesteg
Hello Aleksey,
I am unable to provide you with sample data, as this is generated by Visure Requirements. You probably wouldn't have much use of the template either without the sample data. I will try to explain the best I can what I want to achieve here.
I am using the report designer to create a report that contains all the meta data necessary for filing in our PLM software. These values are stored in the Visure Requirements database in the "Concepts" data table. The entries in the column Concepts.Name is used as key column and does not change. I need to display five values from the column Concepts.Description column on the front page of my report, and I need to identify those five values using the Concepts.Name column. The sample code in my previous post shows how I find one such Concept.Description column, and saves it as plain text in the variable strTCDoc. strTCDoc is shown on the front page of the report as a text box.
Now, if I where to set the variable strTCDoc as Request from user. The value displayed in the variable input field in preview mode is not the same as the value shown in the generated report.
So, if I was able to replace my code from the previous post with Init by: expression, expression = ???

- Edit variable.png (30.06 KiB) Viewed 2386 times
or by entering a expression directly in a text component:

- Front Page.png (67.02 KiB) Viewed 2386 times
that could find a row based on Concept.Name column, and get the value from Concept.Description column it would be great.
Note: I did this using data bands earlier, but as you may imagine, it became a mess with all the databands and panels on the front page.
Thank you.
Re: Find a row in a DataTable using expression
Posted: Mon Aug 19, 2013 12:15 pm
by HighAley
Hello.
You could try to use Get Value event of the text component.
Thank you.