Friday, March 27, 2009

How to set a ReferenceField programmatically

I'm creating a method for importing content into Plone. The content types that are created have a reference field on them, but how to set that from your import method (or import script)?

A ReferenceField simply stores the UID of the referenced object, so you can do it like this (if your field is called myReference:
    obj.setMyReference(referenced_object.UID())

No comments: