Joining a table is easy. In ArcGIS Pro, you simply right-click a table, goto "Join and Relate" and then select "Add Join". This takes you to a Geoprocessing tool where you select the input join field and output join field and voila, your table is joined !
1. But, when it comes to using the "management.AddJoin" with ExecuteToolAsync(), you actually end up with a new table with the two tables joined together:
- var argsAddJoin = gp.MakeValueArray("C:\\Project\\Sample_database.gdb\\Input_Table", "INPUT_ID", "Table_to_Join", "OUTPUT_ID", "KEEP_ALL");
- var resultAddJoin = await gp.ExecuteToolAsync("management.AddJoin", argsAddJoin);
- string resultingJoinedTable= resultAddJoin.ReturnValue;
2. Then, if you want to recalculate a field in the input table, you would have used the following python code:
- // Calculate Field //
- arcpy.management.CalculateField("Resulting_Joined_Table", "Resulting_Joined_Table.FIELDNAME", "!Table_to_Join.FIELDNAME!", "PYTHON3", '', "TEXT")
and expect to use the following code in C#:
- var argsCalculateField = gp.MakeValueArray("Resulting_Joined_Table", "Resulting_Joined_Table.FIELDNAME", "!Table_to_Join.FIELDNAME!", "PYTHON3", "", "TEXT");
- var resultCalculateField = await gp.ExecuteToolAsync("management.CalculateField", argsCalculateField);
But, this won't work. You actually have to reference the original input table that you had "wished to join" in as the input table's name:
- var argsCalculateField = gp.MakeValueArray("Resulting_Joined_Table", "Input_Table.FIELDNAME", "!Table_to_Join.FIELDNAME!", "PYTHON3", "", "TEXT");
- await gp.ExecuteToolAsync("management.CalculateField", argsCalculateField);