Hi Ewerton, I've built this service for this ( I have it on an Infotable Helpers thing 😞
Service Name: FullJoin
Parameters:
- infotable1
- infotable2
- joinFields (STRING) --> Comma separated list of fields to join on ( should have the same name in both infotables )
- infotable2Fields (STRING) -> Comma separated list of fields to add from the infotable2.
- infotable2BaseTypes (STRING) --> Comma separated list of fields baseTypes to add from the infotable2
Code:
var result = infotable1;
var fields2 = infotable2Fields.split(",");
var types2 = infotable2BaseTypes.split(",");
var join = joinFields.split(",");
for(var i=0;i<fields2.length;i++) infotable1.AddField({ name: fields2, baseType: types2 });
var found,objFind = {};
for each(row in infotable1.rows) {
objFind = {};
for(var i=0;i<join.length;i++) objFind[join] = row[join];
found = infotable2.Find(objFind);
if (found!=null) {
for(var i=0;i<fields2.length;i++) row[fields2]=found[fields2];
infotable2.Delete(found);
}
}
for each(row in infotable2.rows) {
result.AddRow(row);
}