Can we create a content fragment and have it automatically published in the publish environment? | Community
Skip to main content
Level 2
May 23, 2023
Solved

Can we create a content fragment and have it automatically published in the publish environment?

  • May 23, 2023
  • 2 replies
  • 1430 views

Good afternoon, I have the following question:

 

We are creating content fragments from the Author Assets API, but we do not know how we can publish it as soon as we create it, since the checks we do are in the "Publish" environment, therefore, we cannot validate that Content Fragment without first publish it manually.

 

The question is... Is there any way to publish it automatically?

 

Thank you so much.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by MayurSatav

hi @alex_terinte ,

In AEM, when creating Content Fragment

using the Author Assets API, you can set the workflow model to automatically publish the Content Fragment upon creation. This way, you can ensure that the Content Fragment is published without manual intervention.

Here are the steps to configure automatic publishing of Content Fragments:

  1. Create a custom workflow model:

    • In the AEM author instance, navigate to Tools -> Workflow -> Models.
    • Create a new workflow model or modify an existing one.
    • Configure the workflow steps to include the necessary validations and actions for your Content Fragments.
    • Add the "Publish" step at the end of the workflow model to trigger automatic publishing.
    • Save and activate the workflow model.
  2. Invoke the workflow model during Content Fragment creation:

    • Use the Author Assets API to create the Content Fragment programmatically.
    • Before saving the Content Fragment, associate it with the configured workflow model by setting the appropriate workflow metadata.
    • Ensure that the workflow model you created in step 1 is used for the Content Fragment.

2 replies

arunpatidar
Community Advisor
Community Advisor
May 23, 2023

Hi @alex_terinte 
It is possible using Workflow Launcher or Writing custom Event Lister to replicate on create event.

Arun Patidar
MayurSatav
Community Advisor and Adobe Champion
MayurSatavCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
May 23, 2023

hi @alex_terinte ,

In AEM, when creating Content Fragment

using the Author Assets API, you can set the workflow model to automatically publish the Content Fragment upon creation. This way, you can ensure that the Content Fragment is published without manual intervention.

Here are the steps to configure automatic publishing of Content Fragments:

  1. Create a custom workflow model:

    • In the AEM author instance, navigate to Tools -> Workflow -> Models.
    • Create a new workflow model or modify an existing one.
    • Configure the workflow steps to include the necessary validations and actions for your Content Fragments.
    • Add the "Publish" step at the end of the workflow model to trigger automatic publishing.
    • Save and activate the workflow model.
  2. Invoke the workflow model during Content Fragment creation:

    • Use the Author Assets API to create the Content Fragment programmatically.
    • Before saving the Content Fragment, associate it with the configured workflow model by setting the appropriate workflow metadata.
    • Ensure that the workflow model you created in step 1 is used for the Content Fragment.
Level 2
May 23, 2023

@mayursatav 

Thank you so much!

Thank you for explaining it in such detail.