Search code examples
tridiontridion-2011

CurrentWorkItem.ID is correct or not in workflow script editor?


I am using Tridion 2011 SP1, And I am creating workflow like start-->create-->Review-->publish--Stop.

I created and registered the class library, and invoke the C# method using VBscript (Script Editor of WF Tab) as given below.

Option Explicit
Dim workflowHandler
Set workflowHandler= CreateObject("CoreComponentWorkflow.WorkflowHandler")
If Not workflowHandler Is Nothing Then
Call workflowHandler.PublishComponent(Cstr(CurrentWorkItem.ID))      
     FinishActivity "Published to WIP"
End If
Set workflowHandler= Nothing

Is the above code is correct? I am sure I am able to create object using the below line.

Set workflowHandler= CreateObject("CoreComponentWorkflow.WorkflowHandler")

And currently I am publishing the current item only using the C# code, am calling the C# function as below.

Call workflowHandler.PublishComponent(Cstr(CurrentWorkItem.ID))      

After publishing the item, I am finishing the activity using below.

FinishActivity "Published to WIP"

I have checked the above code directly in the server by hard coding the currentworkitem, it was working fine. But when I put the same code in vbscript editor, the item is not published.

Can any one suggest on this?


Solution

  • When you hardcode you might be adding the TCM ID directly so it is working properly, which means that CurrentWorkItem.ID is not the correct API call to get the Component ID. See Igor comment below to get the tcm id.