cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Combining specific results from two info tables to another infotables

Bedrock

Combining specific results from two info tables to another infotables

I am needing to combine two Info-tables and display certain information from those on another info-table. I keep getting the error "Error executing service GetSalesOrderPartStyleProduct. Message :: Unable to Execute Union: Field [Customer] was not found in both infotables - See Script Error Log for more details." I understand what it means but cannot figure out where I am going wrong in my code. I created my service which has an info-table output. My thought was switching "Union" to "Join"

var params = {
	infoTableName : "InfoTable",
	dataShapeName : "TrainingDataShape_COB"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(TrainingDataShape_COB)
var myInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

//// result: Two info tables given

var itPartInfo = Things["Training.InfoTable.PartInfo"].GetDataTableEntries(params);
var itOrderInfo = Things["Training.InfoTable.OrderInfo"].GetDataTableEntries(params);

var query = {
    filters: {
        "fieldName":"Color",
        "type": "EQ",
        "value": "Orange"
    }
};

var params1 = {
	t1: itOrderInfo /* INFOTABLE */,
	t2: itPartInfo /* INFOTABLE */

};

// result: INFOTABLE
var result = Resources["InfoTableFunctions"].Union(params1)

var orange = Resources["InfoTableFunctions"].Combine({
	t: myInfoTable,
	columns: "OrderLineID",
    	columns: "SalesOrder",
    	columns: "PartID",
    	columns: "Style",
    	columns: "ProductCode",
	count: undefined,
});

var result = Resources["InfoTableFunctions"].DeriveFields(orange)

 

Tags (2)
1 REPLY 1

Re: Combining specific results from two info tables to another infotables

 

Well I realize what I did wrong in the above code, a lot things. Now my code will only display as, which is progress but not the result i am looking for:

Capture.PNG

 

 

Here is what I came up with now:

var params = {
	infoTableName : "InfoTable",
	dataShapeName : "TrainingDataShape_COB"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(TrainingDataShape_COB)
var myInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

//// result: Two info tables given
var itPartInfo = Things["Training.InfoTable.PartInfo"].GetDataTableEntries(params);
var itOrderInfo = Things["Training.InfoTable.OrderInfo"].GetDataTableEntries(params);

var query = {
	filters: {
		type: "AND",
		filters:
	[
		{
			type: "EQ",
			fieldName: "Color",
			value: "Orange"
		}
	]
  }
};

//Should produce new InfoTable containing desired columns
var params = {
        t1: itPartInfo /* INFOTABLE */,
	t2: itOrderInfo /* INFOTABLE */,
        columns1: 'SalesOrder,OrderLineID,ID' /* STRING */,
	columns2: 'Style,ProductCode' /* STRING */,
	joinColumns1: 'SalesOrder' /* STRING */,
        joinColumns2: 'OrderLineID' /* STRING */,
        joinType: 'INNER' /* STRING */,
};

// result: INFOTABLE
var result = Resources["InfoTableFunctions"].Intersect(params);

var result = Resources['InfoTableFunctions'].Query(
	{
		query : query,
		t : myInfoTable
	}
);