Hi Sergey: I don't have any active connectors that do this sort of filtering, but I don't see any reason why you wouldn't be able to add the filter directly into the connector.
Conceptually, you'll need the following (starting with the end in mind and working backwards through the components).
- A new/update WHERE clause in the connector. An IN(entityFilter)
- The entityFilter which contains of a delimited list of the applicable entities
- The list of applicable entities based on the current workflow
The components to do that might look like (now inverting the order to build up to the final WHERE clause)
'Get our workflow profile entities based on the active workflow
Dim profileEntityInfo = New List(Of WorkflowProfileEntityInfo)(BRApi.Workflow.Metadata.GetProfileEntities(si, si.WorkflowClusterPk.ProfileKey))
'Convert to List(Of String) with only the EntityName.
Dim profileEntityInfoString = New List(Of String)(profileEntityInfo.ConvertAll(Function(x) x.EntityName))
'Create the entityFilter for use in the SQL WHERE clause
Dim entityFilter As String = SqlStringHelper.CreateInList(profileEntityInfoString,True,False)
'Add to our SQL query. NOTE! This asssumes you are using a text.stringbuilder()
sql.AppendLine("WHERE YourColumnThatContainsEntity IN(" & entityFilter & ")")
Again, I haven't tested this in a connector, but hopefully it sets you on the right track.
Cheers -DB
EDIT:
The GetProfileEntities line might need to use api.WorkflowUnitPk.ProfileKey rather than si.WorkflowClusterPk.ProfileKey so it has the correct context. I wrote the above by playing in an extender rather than a connector rule, so please test.