Hi all,
In an automation script, I have information about a table (let's say Table1) which has a foreign key relation to other tables (let's say Table2, Table3, ...). Given Table1 PID, is there a way to get all the linked tables (Table2 PID, Table3 PID, ...)?
Hi Fenta, this is not possible using an out-of-the-box available call.
The only possibility I currently see is through SLNet calls. Below is a snippet that can be used.
Note:
- no safety check included yet in the code
- be careful with SLNet calls as these might change over time
- if you would execute this script frequently, please use some caching to limit the performance overhead.
GetProtocolInfoResponseMessage gpirm = engine.SendSLNetSingleResponseMessage(new GetProtocolMessage("ProtocolName", "ProtocolVersion")) as GetProtocolInfoResponseMessage;
ParameterInfo pi = gpirm.FindParameter(PID OF Table1);
foreach(TableColumnDefinition tcd in pi.TableColumnDefinitions) {
if (tcd.ForeignKeyDestTableID != -1)
{
engine.GenerateInformation($"{pi.Name} is linked to {gpirm.FindParameter(tcd.ForeignKeyDestTableID).Name}");
}
}