Asynchronous process step - SmartPlant Foundation - IM Update 44 - Customization & Programming - Hexagon

SmartPlant Foundation Customization

Language
English
Product
SmartPlant Foundation
Search by Category
Customization & Programming
SmartPlant Foundation / SDx Version
10

To execute the process step class asynchronously, set the ProcessStepRuntimeArgs(True) attribute on the class, which will allow the DontSignOff flag on the workflow step to be set to True. You must ensure that the custom code signs off the step on successful completion of the step class execution.

The following code is an example of an asynchronous process step:

<ProcessStepRuntimeArgs(True)>

Public Class TRNChangeEmailOwner

Inherits ProcessStepBase

Public Overrides Sub Execute()

'

' Get the SPFObjectWorkflowStep object

'

Dim lobjSPFObjectWorkflowStep As ISPFObjectWorkflowStep = CType(StartingObj.ToInterface("ISPFObjectWorkflowStep"), ISPFObjectWorkflowStep)

Try

'

' Process Step class logic execution.

' After execution, consider TRNChangeStatus is 'Issued'

'

Dim lblnTRNStatus As String = "e1Issued"

'

' Check the status of the starting object

'

If String.Compare(lblnTRNStatus, "e1Issued") = 0 Then

'

' SignOff as TRNChangeStatus Is Issued

'

SignOff(lobjSPFObjectWorkflowStep)

Else

'

' Reject the step TRNChangeStatus isn't Issued.

'

RejectStep("Status must be ISSUED before you can Continue.", lobjSPFObjectWorkflowStep)

End If

Catch lobjException As Exception

RejectStep(lobjException.Message, lobjSPFObjectWorkflowStep)

End Try

End Sub

Private Sub RejectStep(ByVal pstrStepRejectMessage As String, ByVal pobjWorkflowStep As ISPFObjectWorkflowStep)

'

' Reject Step

'

SPFRequestContext.Instance.Transaction.Begin()

pobjWorkflowStep.BeginUpdate()

pobjWorkflowStep.RejectStep(pstrStepRejectMessage, pstrStepRejectMessage)

pobjWorkflowStep.FinishUpdate()

SPFRequestContext.Instance.Transaction.Commit()

End Sub

End Class