Quantcast
Channel: VMware Communities : All Content - VMware vCenter™
Viewing all articles
Browse latest Browse all 24426

VMWare VIM SDK .Net, update CustomFieldValue

$
0
0

Hi,

 

I am not sure if this is the correct forum for SDK questions, please redirect me to a correct one if not, but here goes:

 

I have this code:

 

 

 

public void SetFieldValue(int key, string value)

{

    var customField = (CustomFieldStringValue)this.VirtualMachine.CustomValue.Single(cv => cv.Key == key);

 

 

    customField.Value = value;

}

 

 

 

That in itself works, as in, it's visible that the value has changed, but I don't see it reflected upon the actual custom field on the VM when viewed in the vSphere Client.

So, is there a save I need to do, or do I have to change the value in another fashion?

 

Thanks

 

Message was edited by: Ondit

 

 

I've gotten a bit further, looks like I need to use the CustomFieldsManager, but I don't know what to provide as Entity for the SetField method:

 

var mgr = new CustomFieldsManager(this.VimClient, myVM.VirtualMachine.MoRef);

mgr.SetField(???, key, value);


Viewing all articles
Browse latest Browse all 24426

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>