Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear community,
unfortunately there is not so many examples and post available for the usage of dynamic settings.
Here for a checkbox.
I have to decide dynamically, which connection mode for Salesforece (query or bulk) has to be used.
So, I'm able to set the checkbox "Bulk connection" within tSalesforceConnection from a global variable.
Example: "Bulk connection" -> ((Boolean)globalMap.get("name_of_variable_a_stored").
That works correct.
In dependency on the type of the connection, I have to set the "Query mode" within tSalesforceInput to
"Query" or "Bulk" for normal and bulk mode, respectively. And here, the "Query" mode seems to be selected every time, no matter, which value is stored within variable.
Example: "Query mode" -> ((String)globalMap.get("name_of_variable_b_stored").
In the "name_of_variable_b_stored" the string values "Bulk" or "Query" stored dynamically.
If I set the value directly as text into the dynamic settings, that case seems to work
"Query mode" -> Bulk
Is it a bug of tSalesforeceInput ? or do I set the values for a "select menu" in a wrong way ?
(I've tried out to set "1", "2" for selection order and also to covert the string to char-array, no success)
(Talend 7.3.1)
It is difficult to understand what you have done and why it might be failing from the description. Would you mind posting a screenshot of your job and any pertinent settings? It give a clearer idea.
ok, I'll try to reduce the answer to the most important steps
I think I see what you are trying here. I take it you are using the Dynamic Settings tab for this? I believe that this could be to do with a timing issue. When components initialise, their parameters must be set before this. I suspect that that is the problem. Can you give a screenshot of your job so I can see if there is a workaround?
yes, it is about "dynamic settings tab".
I've created a simplified job as response to your question.
I hope the issue and implementation becomes clearer:
p.s. on the right hand side, only one of if-conditions is "true", according to the connection type set
( i.e. ((Boolean)globalMap.get("bulk_connection_flag")) == false for "query mode")
Ah, I see. This makes more sense now. First, this is not actually the problem you are raising here, but I think it may be causing it. Your tPreJob component is not used as it is intended. The tPreJob component should only be linked to components that need to run before the job is run. Once all of the components that need to be run before the job have fired, there is no need to connect the rest of the jobs to this "chain" of jobs. So, I am guessing that your pre job section should stop at "set_global_variables". Also, it is probably best to link the pre job components using OnComponentOK links.
Normally I would also include the Connection component with the pre job stuff, but in this case I would like to try starting the Main job with that component. The reason for this is that context/globalMap variables will be set at this point.
Also, where you have the RunIf components, what are the conditions for these? This could be a situation where these are playing up and while your Connection is being setup correctly, the RunIfs are not firing correctly.
you are right about the wrong usage of tPrejob.
I've just deleted the connection, so the main-job is now in the main part. But ... the same behavior
(The connection component can not be moved to prejob, since in the main-application it is a part of a loop and in dependency on some criteria for each iteration the "bulk" or "query" mode has to be used).
Here the summary again:
If-conditions are triggered correctly
Thanks for raising this @Alexander Mueller, this is indeed a bug. I will get on to raising it immediately. I have recreated it and have knocked up some (granted, quite ugly) code to test this. Since you have pointed this out, I'll give you a copy to play with. It may be useful to you.....
************************************************************************************
org.talend.components.salesforce.SalesforceConnectionProperties props_tSalesforceConnection_1 = ((org.talend.components.salesforce.SalesforceConnectionProperties) globalMap.get("tSalesforceConnection_1_COMPONENT_RUNTIME_PROPERTIES"));
System.out.println("Connection Settings");
List < org.talend.daikon.NamedThing > props = props_tSalesforceConnection_1.getProperties();
for (int i = 0; i < props.size(); i++) {
org.talend.daikon.NamedThing nt = props.get(i);
System.out.println(nt.getName() + " = ");
org.talend.daikon.properties.property.Property tmpProp = props_tSalesforceConnection_1.getValuedProperty(nt.getName());
if (tmpProp != null) {
Object ob = tmpProp.getValue();
if (ob != null) {
if (ob instanceof String) {
System.out.println(((String) ob));
}
if (ob instanceof Boolean) {
System.out.println(((Boolean) ob));
}
}
}
}
System.out.println("");
System.out.println("Input Settings");
org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties props_tSalesforceInput_1 = ((org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties) globalMap.get("tSalesforceInput_1_COMPONENT_RUNTIME_PROPERTIES"));
List < org.talend.daikon.NamedThing > props2 = props_tSalesforceInput_1.getProperties();
for (int i = 0; i < props2.size(); i++) {
org.talend.daikon.NamedThing nt = props2.get(i);
System.out.println(nt.getName() + " = ");
org.talend.daikon.properties.property.Property tmpProp = props_tSalesforceInput_1.getValuedProperty(nt.getName());
if (tmpProp != null) {
Object ob = tmpProp.getValue();
if (ob != null) {
if (ob instanceof String) {
System.out.println(((String) ob));
}
if (ob instanceof Boolean) {
System.out.println(((Boolean) ob));
}
if (ob instanceof org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties.QueryMode) {
System.out.println(((org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties.QueryMode) ob).name());
}
}
}
}
*********************************************************************************************
Just bung that in a tJava at the end of your job and change the class names to match your Salesforce components. It will show you all of the settings that have been made for them.
Unfortunately, this will not help fix your issue.
However, I do have a suggestion. It is not great, but it will work. If you create 2 tSalesforceInput components and decide which one to use via a couple of RunIfs, you can set each to the type of query you want. As I said, not ideal. But I will get this raised immediately.
Thanks for raising this.
Ok, thank you for the analyzing of the issue.