Update Global Variables I've got a custom plugin where I'm trying to update a global variable. The variable field type is of type Entry

I'm getting the set using getSetByHandle then using getContent on the set. However, when I do a count on the retrieved content, the value is 1. I have about 10 global variables so would've expected a count of 10.

I'm clearly doing something wrong, so a nudge in the right direction would be appreciated.

Update

Here's the code I'm currently using

$global_set = craft()-&gt;globals-&gt;getSetByHandle('globalVariables');
$selected_poll = craft()-&gt;entries-&gt;getEntryById($poll_id);
$content = $global_set-&gt;getContent();
craft()-&gt;globals-&gt;saveSet($globalSet);


Update

I've also tried the following, with no luck:

$globalSet = craft()-&gt;globals-&gt;getSetByHandle('tempSet');
$content = $globalSet-&gt;getContent();
$content-&gt;currentItem = craft()-&gt;entries-&gt;getEntryById($itemID);
$globalSet-&gt;setContent($content);
craft()-&gt;globals-&gt;saveContent($globalSet);
Ok figured it out. I was going about it completely the wrong way. As the field in question is an Entry type, I needed to use the Relations Service

$globalSet = craft()-&gt;globals-&gt;getSetByHandle('[globalSetHAndle]');
$selectedField = craft()-&gt;fields-&gt;getFieldByHandle('[fieldHandle]');
craft()-&gt;relations-&gt;saveRelations($selectedField, $globalSet, array($entryId));


Passing null instead of array($entryId) will clear the relation values