How do I find the label names and values for a storage slot?

How do I find the label names and values for a storage slot?

sean_tully
Contributor Contributor
204 Views
1 Reply
Message 1 of 2

How do I find the label names and values for a storage slot?

sean_tully
Contributor
Contributor

I have many storage units (a mixture of racks and floor storage) in a model and within any given storage unit, slot labels are the same for all slots.

How can I check the labels on a given slot programatically?

 

I can access a slot on a given storage unit by e.g.:

string storageName = "MyStorageUnit";
treenode su = Model.find(storageName);
Storage.Slot slot = Storage.system.findSlot("WHERE slot.storageObject == $1", 0, su);

But how do I either find the value for a particular slot label, or find all values for all slot labels for this slot?
I have tried syntax like...

return slot.slotSKU;

...where slotSKU is definitely a valid label applied to all slots in the storage unit, but this gives me the following exception:

exception: FlexScript exception: MAIN:/project/exec/consolescript c: <no path> i: <no path>
0 Likes
Accepted solutions (1)
205 Views
1 Reply
Reply (1)
Message 2 of 2

joerg_vogel_HsH
Mentor
Mentor
Accepted solution

Find_Slot_Labels.jpg

Storage.Object rack = Model.find("Rack_A");
Storage.Slot testSlot = rack.getSlot(3,2,1);//getslot: Bay, Level, Slot
Array allSlotLabels = testSlot.as(treenode).find("slotLabels").subnodes.toArray();
print(allSlotLabels);

enhanced to flatten all slot labels by a slot query and a table query

Array allSlots = Storage.system.querySlots("",0);
Table.query("SELECT $3 AS SLOTLabel FROM $1x$2",
		allSlots.length,
		allSlots[$iter(1)].as(treenode).find("slotLabels"),
		$iter(2)
		).cloneTo(Table("Dump1")); // not necessary as(treenode)
Array allNodes = Table("Dump1").clone();
print(allNodes);

here is an example to get slots by label value:

Array allSlots = Storage.system.querySlots("WHERE slot.storageObject.name = 'Rack_B' AND slot.SKU = 1",0);
print(allSlots);

 

0 Likes