VMware {code} Community
admin
Immortal
Immortal

how to delete a custom field value from a managed object?

Hello,

Using the VI api, I can do the following

- add a custom field definition

- rename a custom field definition

- delete a custom field definition

- set the value of a custom field on a particular managed object

but I can't find any way to clear a custom field from a particular

managed object. Once you set a value you can't clear it anymore (ie

remove the value on the object without removing the global definition).

Am I missing something or is there a non obvious way to do this?

Thanks

0 Kudos
6 Replies
Steve_Jin
Expert
Expert

Have you tried to setField with null value?

Steve JIN, VMware Engineering

Creator of VI Java API:

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
0 Kudos
admin
Immortal
Immortal

I tried that with null and the call doesn't go through, I get a soap exception

failed: System.Web.Services.Protocols.SoapException : value

at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

(I also tried the empty string. But it doesn't remove the custom field.)

0 Kudos
Steve_Jin
Expert
Expert

Then the only option is to remove the def, but it will also remove all the other values that you don't want to remove. You can save the "other" values and then add them back after you recreate the def. It seems to me too much work.

What is the big deal for let it be there? Just try to find other alternatives.

Steve JIN, VMware Engineering

Creator of VI Java API:

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
admin
Immortal
Immortal

Yep, it works by removing the definition, but if you have a VC with hundreds of VMs, it becomes a huge performance impact to remove a custom value from one single VM (you need to issue hundreds of calls).

The API is obviously missing this functionality.

0 Kudos
Steve_Jin
Expert
Expert

Agree. Filed a request on this: 364406.

Steve JIN, VMware Engineering

Creator of VI Java API:

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
0 Kudos
brittj2001
Contributor
Contributor

Any updates on this?  Where can I check on that status of "request 364406"?

Thanks

0 Kudos