LuckyT:
The ID of a Virtual Machine actually looks like this through the SOAP api:
dunes://service.dunes.ch/CustomSDKObject?id='vcenter.yourdomain.lab/vm-744'&dunesName='VC:VirtualMachine'
Try using that format on your line that sets the ID... See if that helps.