Posted on 26/03/2026 08:27:44
HI,
I have created a Data Integration job using an EcomProvider as the source and an XML provider as the destination. A condition on ProductId works as expected when configured directly in the job. However, when I attempt to apply or modify this condition programmatically via a custom scheduled task add-in, the job ignores the condition and exports all products.
In my implementation, I load the job for each product ID, update or create a conditional group on the mappings, then save and run the job. Although the conditionals are set correctly in code, they are not respected during execution. I would appreciate any clarification on this should be handled. below is the code I have so far
foreach (var ProductId in productIds)
{
Job? jobToRun = Job.GetJob($"ExportProductData{Path.DirectorySeparatorChar}ProductDataExport");
if(jobToRun == null)
{
Logger.Current.Error($"Could not find job at path: {jobXmlPath}");
return false;
}
foreach (var mapping in jobToRun.Mappings)
{
var existingGroup = mapping.ConditionalGroups.FirstOrDefault();
var column = new Column("ProductId", typeof(string), mapping.SourceTable);
var mappingConditional = new MappingConditional(jobToRun.Source, column, ConditionalOperator.EqualTo, ProductId, 1, mapping, false) { SourceColumnName = "ProductId" };
if (existingGroup != null)
{
foreach (var existingConditional in existingGroup.Conditionals)
{
existingGroup.RemoveConditional(existingConditional);
}
existingGroup.AddConditional(mappingConditional);
}
else {
var mappingConditionalGroup = mapping.AddConditionalGroup(ConditionalGroupOperator.And);
mappingConditionalGroup.AddConditional(mappingConditional);
}
}
jobToRun.Save();
bool success = jobToRun.Run();
}
PS: this is implemented on DW10