I'm trying to use the event system to auto finish the first step in workflow on initial creation.

My code is fine until oActivity.FinishActivity("Message") - the log is saying I need to specify a nextActivity, but this is not a decision step, and the next activity is an automatic decision, so there is only one nextActivity.

Any ideas why it wants a next step?

Code snippet

oWFComp = oTDSE.GetObject(oNode.Attributes(8).InnerText,
oActivity = oWFComp.ActivityInstance
oActivity.FinishActivity("Creation point")

Every workflow activity must end with the instruction of which is the next activity. IIRC, you can specify Nothing or "" as the next activity if you only have one option.

EDIT I just RTFM'ed:

Public Function FinishActivity(ByVal finishMessage As String, 
                               Optional ByVal nextActivity As String = TDSDefines.URINULL, 
                               Optional ByVal dynamicAssignee As String = TDSDefines.URINULL) 
                               As String

So, it looks like it does NOT need you to specify a next activity (it defaults to URINULL or tcm:0-0-0)

In an old sample I have, I found this code:

FinishActivity("finished by Event System code", Constants.URINULL, Constants.URINULL)

In VbScript, if you wish to pass parameters to a function or sub, the simplest syntax is to just put the parameters in a comma separated list after the function name. Using your example:

oActivity.FinishActivity "Creation point"

If you are more comfortable with parentheses, the Call keyword allows for the alternative syntax:

Call oActivity.FinishActivity("Creation point") 

Either of these will do, but if you mix them, as you have, there won't necessarily be an error message that tells you what's wrong. Instead it will "try its best" and probably give you a confusing error message.

Nuno's example:

FinishActivity("finished by Event System code", Constants.URINULL, Constants.URINULL) 

looks like it might be in C#. Older versions of Visual Studio didn't automatically wire up COM default parameters, so putting in Constants.URINULL was necessary. Of course, in C# there's no Call keyword, and you always need the parentheses.


Issue resolved - it turns out I had broken an if statement around the above code, so it was running for ALL components on that workflow diagram, rather than just the individual component I had intended. One of the components it ran on was at a decision step, hence the message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.