How I can set exchange.getIn().getMessageId() in to variable and pass it through ContextParam in cTalendJob to my Job? I can pass String like "bla bla bla", but when I try pass variable like
`
${myVariable},
#{myVariable},
{myVariable},
$myVariable,
context.myVariable
I get error myVariable cannot be resolved a variable.
Someone knows how to do it?
You can get a variable in a job from a route with the configuration of tRouteInput.
In the tRouteInput write somethings like that:
${header.typesOfParametre.nameOfParametre}
header if you put the variable in the header...
I hope i helped you
If, like me, you didn't want to change the tRouteInput component of your job, but just set a context parameter for the job from ${myvariable} in your route, then there is a slightly ugly way of doing it.
I wanted to set the context parameter from a message header, so I created a cSetHeader component and set a header matching the context parameter name, which allows you to select the expression language and therefore in simple you can have ${header.headerName}.
In the "Advanced Settings" tab of cTalendJob, select the "Propagate Header" checkbox and this will populate any context variables that exactly match the name of the message headers.
This has worked for me, but for completeness and safety, you might want to make sure you strip any headers you don't need in case they overwrite other context variables in the Talend job.
Related
In Jitterbit Dataloader 10.37 I want to create CSV-files from Salesforce data but only if the query returns data.
I checked "do not create empty files" on the target type local file but it is still creating a csv just with the header but with no data. I do not want files created with no data in it. It is not an option to not have the header at all in the files - I will need it when there is data from the query.
Any suggestions? What am I missing?
I've seen this happen in situations where the write operation is after a couple of other operations. In that instance a header is written in the first operation, then another header is written in a second operation. The first row is read as the header, the second row (another header) is read as data, and written out.
I always add in a condition where I check if one of the fields equals its name. Something like this, to just skip those rows.
<trans>
if(Id=="Id",
false;,
true;
);
</trans>
The best way to do this is to send your output to a variable array. Then check the variable to see if data is present. So set your target to a global variable. Then add a script after that target and do your validation. To test your script use DEBUGBREAK(); to test and look at your variable content. That way you can see what is going into it.
Then make your condition statement.
if( Length($varailbe)>1,RunOperation("operation:myexport"),"novalue"):
I have an SSIS Project I want to parameterise to be able to have dev, staging, production environments.
I'm starting slowly, and I'd like to parameterise some hardcoded filepaths.
I have a foreach loop container that iterates over a directory and performs some actions on each of the files it contains.
In Visual Studio I right click and click edit. There are four tabs: General, Collection, Variable Mappings, and Expressions.
Under "Collection", there is a variable Folder. This is hardcoded currently. I'd like it to be at least a package parameter, or preferable, a project parameter followed by a suffix.
Once I've added a project parameter, how can I do this?
For this purpose, let's say I have a variable: SuperFolderLocation.
Would I change the variable Folder's destination to be #[$Project::SuperFolderLocation] + "\subdirectory"? Do I need to use expressions to calculate the variable Folder's destination? If so, what is the variable I need to set? And can you just plop a variable in the Folder destination and it will interpret it?
First thing you need to do is create the project parameter:
Then in the foreach loop container select collection and make sure that "Foreach File Enumerator" is selected in the drop down.
Click on Expressions and select "Directory" in the Property dropdown.
Click on Expression ellipsis and this will open the Expression Builder
Then select your parameter from System Variables and complete the expression by adding the subfolder.
You can also click on button Evaluate Expression to make sure the path is correctly evaluated.
I have a build up a report with a .CSV input file as DataAdapter. After that I needeed a table to put some data into a it and a linked dataset. The problem is: if I leave blank the section "Default Data Adapter" in my Dataset1, no data will be displayed. In fact, to fix this report I had to export my DataAdapter as myDataAdapter.xml and then put this file in the section "Default Data Adapter" of my Dataset1 (as shown in the attached picture).
Working with database I have never set up this property.
Is there a way to pass this property as Param? (I have a java code in which I call jasperReport and I want to pass this object dinamically).
Or is there a way the report works without setting this property?
In the section Table>Dataset I have this situation:
where I set up JRDatasource expression, but it is not working...
I have one more problem. Can I set dinamically the location of my .csv inside the DataAdapter.xml?
Is it possible to implement "myDataAdapter.xml" from java code and pass it to the report??
Thank you in advance!
In Java code you can set properties on the net.sf.jasperreports.engine.JasperReport instance like in this sample here, from the official repository. The relevant code looks like this:
...
JasperReport jasperReport = ...
...
jasperReport = (JasperReport)JRLoader.loadObjectFromFile("build/reports/ExcelXlsxQeDataAdapterReport.jasper");
jasperReport.setProperty(DataAdapterParameterContributorFactory.PROPERTY_DATA_ADAPTER_LOCATION, "data/XlsxQeDataAdapter.xml");
...
The property of interest is net.sf.jasperreports.data.adapter and is stored in DataAdapterParameterContributorFactory.PROPERTY_DATA_ADAPTER_LOCATION
The data adapter file is a convenience method to pass a series of parameters from which a net.sf.jasperreports.engine.data.JRCsvDataSource is built. If you want to skip passing this property, you would have to manually provide the built-in parameters listed in the net.sf.jasperreports.engine.query.JRCsvQueryExecuterFactory.CSV_BUILTIN_PARAMETERS.
I have created build promotion "choice" parameter named "RUNSCRIPT" with values "No" (as default) and "Yes" and trying to get the value of parameter in EXEC SHELL command as $RUNSCRIPT but neither value "Yes" or "No" coming through. If I look at the output it comes as $RUNSCRIPT (as it is). Why is not being replaced with value. Any suggestions? Also, tried to create other type of parameters e.g. String value but its not working as well.
If you want to pass a value from jenkins to a script you need to define the parameter as jenkins environment variable. I have used Ant for this. For example :
property environment="env"
property name="user" value="${env.user}"
if I just use
property name="user" value="${user}"
the values will be passed from some other file that is referring user.
I managed to get an Approval Parameter to be passed as a Build Parameter on a downstream build (triggered by the promotion itself); you simply need to pass them on.
I learned that Approval parameters are allowed within the approval "build" so to speak, so any actions you have in that approval should be able to reference any of the Approval parameters.
This means you can have an approval parameter FOO, and then in the approval actions, if you have a "Trigger parameterized build" action, you can use a "Predefined parameters" with the text:
BAR=${FOO}
The triggered build will then have the BAR build proprerty set with the value of whatever the build was promoted with.
In Reporting Services I would like to add a parameter that contains data from a custom code block. Ideally, I would be able to run the following code (this is a simple testing example):
Function GetPeriods() As String()
Dim values As System.Collections.ArrayList =
New System.Collections.ArrayList()
For i as integer = 1 to 24
values.Add(i)
Next
Return values.ToArray()
End Function
and put the following in the "Text Field" of the parameter:
=Code.GetPeriods()
However, when I run the report, the parameter I apply this to is disabled and empty. Is there a different technique that should be used? Or am I doing something wrong?
If you're using SQL 2008 Reporting Services then you can have a look at this page which introduces the concept of using custom assemblies.
If you're using SQL 2005 Reporting Services then this link is the one you want.
It's a mostly trivial thing, simply compile your code into a class library and follow the instructions provided to allow your report to reference it.
You are returning an array item (an array of strings) into a text field. Instead, try returning a plain string. That should work. If you would still like to return an array list, you must basically bind it to a list control in your RDL. You can definitely do that with dataset extensions. However, I am not sure if there is any other easy way. Check the proprties of the list control and see if it allows you to directly bind to an array list.
You can create the same stored procedure on SQL Server and load parameter values from that procedure.
To access your members/functions implemented in custom code of SSRS report you should set the access modifier to "Public":
Public Function GetPeriods() As String
...
see article Writing Custom Code in SQL Server Reporting Services
I've been trying to do this same thing, set a simple list of parameter values from report code. None of the links in any of these answers shows how to do this and after quite a bit of digging around I don't think it's even possible. Yes it is possible to get the values from a database query, from a web service, or from a custom assembly, but each of these creates a lot of overhead compared to getting the list from a simple function call like =Code.GetValues(), where the function uses a For loop to create the values.
msvcyc is correct in pointing out that the parameter is expecting a string value, but the function is returning an array. I changed the return type to Array as suggested by prashant sable, but the select list is still grayed out, it does not work. And coldice is correct in saying that the access modifier should be Public.
In my digging around I found an article by James Kovac from 2005 that pointed out why this is not possible. The Parameters class has a get method, but no set method. In the VS 2008 object browser for SSRS 2008 the object name has changed, but it still does not contain a set method (see Microsoft.ReportingServices.Interfaces.IParameter.Name or .Value).
My current workaround is to just hard code the list of values, but if your value list needs to be dynamic then your only choices are database queries, web services, or custom assemblies. I think the easiest workaround of these three is to get the values from the database engine, as suggested by oleksiy.t, as long as you can write a query to return the value list you want. Your list of integers, or my list of time intervals, would both be easy queries to write. Otherwise you will need to use one of the other two workarounds.
I checked your code. The only thing that's wrong is your function returns String(). When I changed your method signature to return Array, it worked fine, in my report.
Change the signature to Function GetPeriods() As Array
Everything I've seen requires parameters and their respective settings to be part of the RDL.
That being said, if you're going to "hardcode" the values, you could create a dataset just for the report, perhaps in XML, or if it needs to be programmatically driven, do it in a web service.