user1453602
user1453602

Reputation: 1165

Publishing page from workflow

Whenever page is created or modified we want it to be published to Staging target. For this we have Manual Activity "Create or Edit Page", then we have automatic activity "Publish to Staging" in this we have written following code, but page is not getting published when it is created or modified. Also no error is shown how to debug where things are going wrong.

' Script for Automatic Activity Content Manager Workflow

Set oTDSE = CreateObject("TDS.TDSE")
Call oTDSE.Initialize
Set ObjCurrentItem = CurrentWorkItem.GetItem(3)
sDestinationServer = "tcm:0-2-65538"
Set oPage = oTDSE.GetObject(ObjCurrentItem.ID, 3) 

Call oPage.Publish(sDestinationServer, True, True, True)

FinishActivity "Publish to Staging for Review"

set oPage = Nothing
set ObjCurrentItem = Nothing
set oTDSE = Nothing

Upvotes: 2

Views: 353

Answers (3)

Vinod Bhagat
Vinod Bhagat

Reputation: 481

As you can see this is a very old code but works to publish objects via Workflow. "This code also publishes the pages/where this items is referenced."

Apart from looking at various logs, would suggest set the clean=false and check till what point the packages are created. This will give you idea how far it has reached. Ofcourse put bit of debug messages to see if all executes well.

Sub WFPublishPages(  ByRef oComponent,  ByRef targets,  ByRef activateBlueprinting,  ByRef activateWorkflow,  ByRef rollbackOnFailure,  ByRef publishTime,  ByRef unpublishTime,  ByRef deployTime,  ByRef resolveComponentLinks,  ByRef priority,  ByRef ignoreRenderFailures,  ByRef maximumRenderFailures )



'    If IsNull(publishTime) Then
'        publishTime = 0
'    End If
'    If IsNull(unpublishTime) Then
'        unpublishTime = 0
'    End If
'    If IsNull(deployTime) Then
'        deployTime  = 0
'    End If
'    If IsNull(resolveComponentLinks) Then
'        resolveComponentLinks = True
'    End If
'    If IsNull(priority) Then
'        priority = PublishPriorityNormal 
'    End If
'    If IsNull(ignoreRenderFailures) Then
'        ignoreRenderFailures = false
'    End If
'    Is IsNull(maximumRenderFailures) Then
'        maximumRenderFailures = 0
'    End If


    Dim Debugstring 
    Debugstring = ""

    Dim oLRF  
    Set oLRF = TDSE.CreateListRowFilter()

        Call oLRF.SetCondition("ItemType", ItemTypePage)
        Call oLRF.SetCondition("OnlyLatestItems", True)
        Dim oXML
        Set oXML = CreateObject("MSXML2.DOMDocument.6.0")
            Call oXML.setProperty("SelectionNamespaces", "xmlns:tcm=""http://www.tridion.com/ContentManager/5.0"" xmlns:xlink=""http://www.w3.org/1999/xlink""")

            Call oXML.loadXML(oComponent.Info.GetListUsingItems(XMLListID, oLRF))

            Dim oNode 
            Dim oPage 
            Dim strPageID
            Debugstring = Debugstring & " DUBUG: ComponentID " & oComponent.ID & vbCrLf
            For Each oNode In oXML.selectNodes("/tcm:ListUsingItems/tcm:Item")
                strPageID = oNode.selectSingleNode("@ID").text
                Debugstring = Debugstring & " DUBUG: PageID " & strPageID & vbCrLf
                Set oPage = TDSE.GetObject(strPageID, OpenModeView )

                Debugstring = Debugstring & " DUBUG: oPage.Title " 
                Debugstring = Debugstring & oPage.Title 
                Debugstring = Debugstring & vbCrLf


                    Call oPage.Publish(targets , activateBlueprinting, activateWorkflow, rollbackOnFailure, publishTime, unpublishTime, deployTime, resolveComponentLinks, priority,ignoreRenderFailures,maximumRenderFailures )
                    Call WriteLog("Publish  Page: " & oPage.Title & " for component " & oComponent.Title &  " - renderTime is " & publishTime & " - deployTime is " & deployTime)
                Set oPage = Nothing
                Set oNode = Nothing          
            Next

        Set oXML = Nothing
    Set oLRF = Nothing

Thanks Vin

Upvotes: 1

Alex Klock
Alex Klock

Reputation: 1526

Since you mentioned this is your first workflow implementation, here are some other basics to try/look for. Since this is a Page Workflow, I'm assuming that the Structure Group that you are creating/editing the page in has already been associated to a Workflow Process Definition in that SG's workflow tab.

  1. Create a new page (or edit a page) in the SG with the Workflow process definition set.
    • Verify that the Page is locked and in Workflow. From the Shortcuts section, goto "My Tasks". You should see your page there. If not, then the SG is probably missing the Process Definition.
  2. Right click the page from "My Tasks" and click "Finish Activity". This should finish your Manual Step and send it to your Automatic Activity. That Activity should then execute the script, which will publish the page and then finish the automatic activity, sending the workflow process to your next step.
    • Verify that the Page has been published (check publishing queue).
    • If the page has not been published, go to the page and check its status. If an error happens during an Automatic Activity, the workflow item will be "suspended" and stuck on that activity. If you see this, you can get details of the error from the Event Log under Source "Workflow Script".

If following the above, and the workflow item is moving along the workflow process correctly (getting past your automatic activity without error and to your next activity) and you are still not seeing it being published, then verify what Nuno suggested.

Also note that you don't have to open the page using the TDSE object as you already have it opened via the CurrentWorkItem.GetItem() method... your script can be shortened:

Dim ObjCurrentItem
Set ObjCurrentItem = CurrentWorkItem.GetItem()

Call ObjCurrentItem.Publish("tcm:0-2-65538", True, True, True)
FinishActivity "Publish to Staging for Review"

Set ObjCurrentItem = Nothing

Upvotes: 3

Nuno Linhares
Nuno Linhares

Reputation: 10234

Here's a few things you can test:

  1. Run the publisher in debug mode (stop the service, open a command prompt, run c:\Program Files (x86)\Tridion\bin\TcmPublisher /debug) and check for errors
  2. Try publishing the page from the "My Tasks" view
  3. Check if your page's current approval status is higher or equal than the Publication Target's "Minimum approval Status"

Upvotes: 0

Related Questions