Execute pre-import script - Data stream

sunilsargam
Kilo Sage

I need to pass a single input parameter to a Data Stream using the Pre-Import Script.

I've already defined this input parameter in the Data Stream configuration.

I've also set up a Scheduled Import and linked it to a Data Source.

In the Data Source, I selected the type as Data Stream, and below that, I can see the input parameter fields where I can provide values dynamically.

7 REPLIES 7

@sunilsargam ,

Try without wrapper.

MIftikhar_0-1760604636307.pngMIftikhar_1-1760604648672.png

 

// Do NOT wrap this in a function: the script already has access to 'data_source' and 'import_set' by default.

(function(import_set_run, data_source) {
   ...
})(import_set_run, data_source);
Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

Kalaiarasi A
Tera Contributor

Try to use this 

data_source.data_stream_action_inputs.<action input name>

instead of  

data_source.setParameterValue

Luiz Martins1
Tera Contributor

 

Still does not work for me either.

As a workaround, I found where the Data Stream input value is stored in sys_variable_value and updated that record before running the Scheduled Import.

I tried the approaches mentioned here, including:

data_source.setParameterValue('<parmName>', value);
data_source.data_stream_action_inputs.<action input name>

I also tested both with and without the wrapper:

(function(import_set_run, data_source) {
   // ...
})(import_set_run, data_source);

In my case, data_source.setParameterValue always returns undefined, and the value does not appear in the Data Stream execution runtime input.

The Pre-Import Script is definitely running, because my gs.info() logs are being generated. However, the Data Stream Action execution still shows the input runtime value as empty.

The only workaround that worked for me was updating the corresponding sys_variable_value record directly before executing the import.