code: def update_role_mappings(obj, wfs=None, reindex=True):
      
      wftool = api.get_tool("portal_workflow")
      if wfs is None:
          wfs = get_workflows()
      chain = wftool.getChainFor(obj)
      for wfid in chain:
          wf = wfs[wfid]
          wf.updateRoleMappingsFor(obj)
      if reindex is True:
          obj.reindexObject(idxs=["allowedRolesAndUsers"])
      return obj
docs: Update the role mappings of the given object