Skip to content

How to schedule publication state programmatically? #144

Description

@xtul9

Hi, I have a (probably niche) use case - I need to set publication date of an entity within my own plugin's service.

I don't understand how to do that. I figured out that if I want to publish or un-publish an entity, I can just utilize publish service like so:

const QUIZ = 'plugin::quiz.quiz';

export default ({ strapi }: { strapi: Strapi }) => ({
  saveQuiz: withTryCatch(async (body: any): Promise<ServiceResponse<any>> => {
    const { quiz }: { quiz: Quiz } = body;

    const { publish } = strapi.plugin('publisher').service('publicationService');

    // Save the quiz
    const savedQuiz = await strapi.entityService!.create(QUIZ, { data: quiz });
    
    // Publish the quiz
    await publish(QUIZ, savedQuiz.id);
    
    // ...
  }),
});

But I've been browsing the code and I still can't figure it out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions