In the case of IAfterTransitionEvent, I try to capture a public object event and when the object is published, two objects are created and I want to link them.
In the xml file type of the object that is being published, I added to the behavior:
element value="plone.app.relationfield.behavior.IRelatedItems"
So that I can get related items.
In my event function, I have:
@grok.subscribe(InitialContract, IAfterTransitionEvent)
def itemPublished(obj, event):
site = api.portal.get()
if event.status['action'] == 'publish':
house_agreement = customCreateFunction(container...,type..)
labor_contract = customCreateFunction(container....,type)
relIDs = []
relIDs.append(RelationValue(IUUID(house_agreement)))
relIDs.append(RelationValue(IUUID(labor_contract)))
obj.relatedItems = relIDs
Unfortunately, printing obj.relatedItems gives me an empty list, and when I go to the View class and browse under the category, the Related Items field is empty. I tried _relatedItems instead of relatedItems, but this does not seem to work, as I think it creates an attribute for obj. I also tried using IUUID instead of converting it to RelationValue, but that does not give me any error at all.
, relatedItems, , , .
, ?
, , .