code: def changeWorkflowState(content, wf_id, state_id, **kw):
      
      portal_workflow = api.get_tool("portal_workflow")
      workflow = portal_workflow.getWorkflowById(wf_id)
      if not workflow:
          logger.error("%s: Cannot find workflow id %s" % (content, wf_id))
          return False
  
      wf_state = {
          'action': kw.get("action", None),
          'actor': kw.get("actor", api.get_current_user().id),
          'comments': "Setting state to %s" % state_id,
          'review_state': state_id,
          'time': DateTime()
      }
  
      # Change status and update permissions
      portal_workflow.setStatusOf(wf_id, content, wf_state)
      workflow.updateRoleMappingsFor(content)
  
      # Map changes to catalog
      indexes = ["allowedRolesAndUsers", "review_state", "is_active"]
      content.reindexObject(idxs=indexes)
      return True
docs: Change the workflow state of an object
      @param content: Content obj which state will be changed
      @param state_id: name of the state to put on content
      @param kw: change the values of same name of the state mapping
      @return: True if succeed. Otherwise, False