If you need a solution for providing ids (by means of search condition) to another workflow, you may want to use a code workflow wf_ExecuteSearchWorkflow.xml (see more below) that executes a search before calling another workflow.
wf_ExecuteSearchWorkflow.xml requires two case-sensitive parameters:
•wfName: (mandatory) the name of the main workflow (without 'wf_' prefix) to execute.
•XQuery: (optional) the query to perform before running the main workflow.
The ids returned by this query are passed to the main workflow.
Example for srv4
srv4 wf ExecuteSearchWorkflow -pars "wfName:myWorkflowName;XQuery:gn4:story[gn4:title='my story title'];" -in "c:\temp\myImage.png"
<?xml version="1.0" encoding="utf-8"?> <!-- Miles33/Tera DP --> <!-- workflow which performs a search to find the ids to pass to another workflow. Parameters: 'wfName': (mandatory) the name of the main workflow (without 'wf_' prefix) to execute.
'XQuery': (optional) the query to perform before running the main workflow. The ids returned by this query are passed to the main workflow. --> <codeWorkflow xmlns="http://www.teradp.com/schemas/GN4/1/WFRes.xsd"> <Members> <![CDATA[ Sub LogInfo(message As String) LogMessage(message, TeraDP.GN4.Workflow.LogEntry.LogCode.Info) End Sub
Sub LogWarning(message As String) LogMessage(message, TeraDP.GN4.Workflow.LogEntry.LogCode.Warning) End Sub
Sub LogError(message As String) LogMessage(message, TeraDP.GN4.Workflow.LogEntry.LogCode.Error)
'we want to stop the execution if an error occurs, so throw an exception Throw New TeraDP.GN4.Common.GenericException(message) End Sub
Sub LogMessage(message As String, code As TeraDP.GN4.Workflow.LogEntry.LogCode) If String.IsNullOrEmpty(message) Then Return 'nothing to do
Dim logAct As Log = New Log(Context) With {.Name = "log message"} logAct.Code = code logAct.Message = message Dim logRes As LogResult = logAct.Do() End Sub ]]> </Members> <Sequential> <![CDATA[ 'check input parameters Dim workflowName As String = Context.ParValue("wfName") If String.IsNullOrEmpty(workflowName) Then LogError("Missing 'wfName' parameter.") Return End If Dim xQuery As String = Context.ParValue("XQuery")
'search for GN4 object ids Dim ids As IList(Of Integer) = New List(Of Integer)(Context.ObjectIds) If Not String.IsNullOrEmpty(xQuery) Then Dim searchAct As Search = New Search(Context) With {.Name = "search ids"} searchAct.XQuery = xQuery Dim searchRes As SearchResult = searchAct.Do() If searchRes.IdsCount > 0 Then ids = searchRes.IdsOut End If LogInfo(String.Format("Found {0} ids.", searchRes.IdsCount)) End If
'execute the main workflow Dim execAct As ExecuteSequentialWorkflow = New ExecuteSequentialWorkflow(Context) With {.Name = "execute workflow"} execAct.WorkflowName = workflowName execAct.ObjectIds = ids execAct.Data = Context.Data Dim execRes As ExecuteSequentialWorkflowResult = execAct.Do() ]]> </Sequential> </codeWorkflow>
|