Avatar

Correct answer by
Level 4

Hi @Hari_07 ,

If all you need to do is combine several columns to one, then I suppose you can do that in an enrichment or inside data extraction itself. The advanced expression editor provides a list of functions that you can use to check the data. To append the results to a single column, you may convert all data to string (use ToString() function) and use '+' to concatenate.

Krishnanunni_0-1625486145571.png

 

 

If you feel the functions inside advanced expression editor is not enough or the combined column becoming too messy, you may use a JS code similar to below. This will fetch the contents from the inbound transition (you can specify the table and query condition in queryDef itself by entering the schema name manually and adding where clause in queryDef). You may specify the columns needed inside the select tag. Then you can iterate each row and join the content to a single string as you desire. So all your null checks can be done inside the loop itself. The final string can be added to an array or written to a file directly using the writeln() function of the File class.

 

 

var schemaName = vars.targetSchema.substr(vars.targetSchema.indexOf(":") + 1);
// This is to fetch content from temp schema to JS
var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="[target/@phone]"/>
<node expr="[target/location/@city]"/>
</select>
</queryDef>
);

var resultSet = query.ExecuteQuery();
var file = new File("filepath");
file.open("w", File.CODEPAGE_UTF8);
for each (var row in resultSet.*) {
// all conditions goes here
logInfo(row.target.location.@city)
// write to file using file.writeln(Combined string)
}

 

 

Hope it helps!

View solution in original post