Skip to main content
replaced http://tridion.stackexchange.com/ with https://tridion.stackexchange.com/
Source Link

Is it possible to catch if an action is Publish or UnPublish in the SetPublishStateEventArgs?

I see in this postthis post I can use the PublishOrUnPublishEventArgs.

Here is the code:

public MyEventSystem() 
{
    EventSystem.Subscribe<RepositoryLocalObject, SetPublishStateEventArgs>(GetPublishInfo, EventPhases.TransactionCommitted);
}

private void GetPublishInfo(RepositoryLocalObject subject, SetPublishStateEventArgs args, EventPhases phase)
{
    
    foreach (var item in args.ProcessedItems)
    {
        string title = subject.Title;
        string publicationTarget = args.Target.Title;
    }
}

Is it possible to catch if an action is Publish or UnPublish in the SetPublishStateEventArgs?

I see in this post I can use the PublishOrUnPublishEventArgs.

Here is the code:

public MyEventSystem() 
{
    EventSystem.Subscribe<RepositoryLocalObject, SetPublishStateEventArgs>(GetPublishInfo, EventPhases.TransactionCommitted);
}

private void GetPublishInfo(RepositoryLocalObject subject, SetPublishStateEventArgs args, EventPhases phase)
{
    
    foreach (var item in args.ProcessedItems)
    {
        string title = subject.Title;
        string publicationTarget = args.Target.Title;
    }
}

Is it possible to catch if an action is Publish or UnPublish in the SetPublishStateEventArgs?

I see in this post I can use the PublishOrUnPublishEventArgs.

Here is the code:

public MyEventSystem() 
{
    EventSystem.Subscribe<RepositoryLocalObject, SetPublishStateEventArgs>(GetPublishInfo, EventPhases.TransactionCommitted);
}

private void GetPublishInfo(RepositoryLocalObject subject, SetPublishStateEventArgs args, EventPhases phase)
{
    
    foreach (var item in args.ProcessedItems)
    {
        string title = subject.Title;
        string publicationTarget = args.Target.Title;
    }
}
Tweeted twitter.com/#!/StackTridion/status/552773076489101312
Source Link
robrtc
  • 10.2k
  • 2
  • 16
  • 35

Catching Published or UnPublished in the SetPublishStateEventArgs

Is it possible to catch if an action is Publish or UnPublish in the SetPublishStateEventArgs?

I see in this post I can use the PublishOrUnPublishEventArgs.

Here is the code:

public MyEventSystem() 
{
    EventSystem.Subscribe<RepositoryLocalObject, SetPublishStateEventArgs>(GetPublishInfo, EventPhases.TransactionCommitted);
}

private void GetPublishInfo(RepositoryLocalObject subject, SetPublishStateEventArgs args, EventPhases phase)
{
    
    foreach (var item in args.ProcessedItems)
    {
        string title = subject.Title;
        string publicationTarget = args.Target.Title;
    }
}