By hari, 4 April, 2023 Example how to update moderation state for your entity programmatically. Included  RevisionLogInterface <?php use \Drupal\Core\Entity\RevisionLogInterface; $new_state = 'published'; $entity->set('moderation_state', $new_state); if ($entity instanceof RevisionLogInterface) { $entity->setRevisionLogMessage($form_state->getValue('revision_log')); $entity->setRevisionUserId($this->currentUser()->id()); } $entity->setPublished(TRUE); $entity->save(); <?php use \Drupal\Core\Entity\RevisionLogInterface; $new_state = 'draft'; $entity->set('moderation_state', $new_state); if ($entity instanceof RevisionLogInterface) { $entity->setRevisionLogMessage($form_state->getValue('revision_log')); $entity->setRevisionUserId($this->currentUser()->id()); } $entity->setUnpublished(); $entity->save(); NOTE: Before 8.3 Use setPublished(TRUE) or setPublished(FALSE) to programatically make published and unpublished content. After 8.3> Replace setPublished(TRUE) with setPublished() Replace setPublished(FALSE) with setUnpublished() Tags Drupal Moderation Workflow