Hi Laurens,
Updating an object is easy:
obj.set("MyAttribute","lorem ipsum");
As for returning an object, there is no such concept when it comes to widgets.
What you should do is define a microflow with a single parameter, which can be of the same entity as the enclosing data view for example. Then in your widget, call this microflow for example when a user clicks a button in your widget or every X seconds. See mx.data.action for documentation on calling microflows from javascript - https://apidocs.mendix.com/6/client/mx.data.html
-Andrej
Works perfectly! Thanks again Andrej and Eric.