GetComponentKey
Called to get the equipment associated with the key value.
GetComponentByKey and SetComponentKey only works with transport equipment, not with products.
To find product try the function GetProductFromID where identifier parameter is product.Identifier.
🔁 Function
object GetComponentByKey(
userPropName: string,
keyValue: number);
⚙️ Parameters
| Name | Type | Description |
|---|---|---|
userPropName |
String | The name of the user property that is to be the key value |
keyValue |
Number | The value of the key |
↩️ Return Value
The return value is the equipment with the associated key value, this call will return null if the key value cannot be found.
📝 Example
function OnSimulationStart() {
SetComponentKey("LocationID");
}
function ProductTracking(msg, hdr) {
var product = UpdateProductPosition(GetComponentByKey("LocationID", msg.locationid), msg.distance, msg.BC);
if (product != null) {
product.Text = msg.BC;
product.Length = msg.l;
product.Width = msg.w;
product.Height = msg.h;
product.Direction = msg.d;
}
}