Writing Key schedule to doors without ungrouping

Hi,
I am using a dynamo script to write key values (from key schedule) to doors. My key value for each door is read from excel. I have key schedule already in Revit. My key value name is “Hardware Set Number”. Its working fine in normal case. But if the Revit project have groups, its prompting to ungroup while executing the dynamo script. Is there anyway can do this successful without ungroup. Thanks for help in advance.
Attached is my script and prompt screenshot.

07_Writing Hardware set Key values to Doors.dyn (23.8 KB)
Capture

Hi, check out this discussion.

It is on my list to revisit the duplication problem I ended up with. :thinking: