Plone Workflow Script KeyError

277 views Asked by At

I have this workflow script;

## parameters = state_change
wf = context.portal_worfklow
catalog = context.portal_catalog
object = state_change.object
path = '/'.join(object.getPhysicalPath())
brains = catalog.searchResults(path={'query':path, 'depth':1}, portal_type='myportaltype', review_state='draft')
if object.TransactionType.lower() == 'sometype':
    for brain in brains:
        obj = brain.getObject()
        wf.doActionFor(obj, 'approve')

I want the script to automatically transition from draft into approved on all sub contents of this folder where portal_type is equal to myportaltype. But I always got an KeyError, it says on the line => wf.doActionFor(obj,'approve'). However, I already reviewed the workflow for myportaltype and its next transition is approve. Is there any problem on my code or lacks something?

1

There are 1 answers

0
user1225163 On BEST ANSWER

As I have discovered, there was nothing wrong with the codes only that I missed this line of code at the top of the script:

##bind context=context