VMware Cloud Community
dcoulter
Enthusiast
Enthusiast
Jump to solution

Delete a Custom Property

Hello, I was looking for a way to remove a custom property, like from a menu operation that calls a workflow to "remove" a component and the associated custom properties.  I've looked in the CDK activities but looks like only get and set for custom properties are exposed.

Reply
0 Kudos
1 Solution

Accepted Solutions
JKougoulos
Enthusiast
Enthusiast
Jump to solution

Hi,

I believe you could use the "DeleteObject" activity from Dynamicops.Repository.

eg.

use a variable of type VirtualMachineProperty eg vmprop

Assign vmprop = mgmtCtx.VirtualMachineProperties.Where( Function(vmp) vmp.VirtualMachine.VirtualMachineName = MachineId).Where( Function(vmp) vmp.PropertyName = "yourproperty").FirstOrDefault()

DeleteObject (mgmtctx,vmprop )

SaveChanges ( mgmtctx)

Regards,

John

View solution in original post

Reply
0 Kudos
2 Replies
JKougoulos
Enthusiast
Enthusiast
Jump to solution

Hi,

I believe you could use the "DeleteObject" activity from Dynamicops.Repository.

eg.

use a variable of type VirtualMachineProperty eg vmprop

Assign vmprop = mgmtCtx.VirtualMachineProperties.Where( Function(vmp) vmp.VirtualMachine.VirtualMachineName = MachineId).Where( Function(vmp) vmp.PropertyName = "yourproperty").FirstOrDefault()

DeleteObject (mgmtctx,vmprop )

SaveChanges ( mgmtctx)

Regards,

John

Reply
0 Kudos
dcoulter
Enthusiast
Enthusiast
Jump to solution

Thanks John, that worked perfectly!

Reply
0 Kudos