I have a extensible rule called "A" to update my Derivative transformation rule group. Now during the workflow execution , i want to run A just before the transformation step.
step1- Load the file.
step2 - Before running the transformation , I want to execute A
Where can I add the business rule so that it runs atleast before the derivative transformation kicks in?
Hi @OS_Pizza !
I am not sure of understanding but, if you add a workspace before your import, you could use this with a WF event handler to run the rule in the workspace. (Or even Add a button on the workspace).
Do you need the LOAD before the execution of A? Or are you flexible on that part?
@NicolasArgenteA will be updating the transformation table, so requirement would be to run before it transforms the data.
To capture the moment just before transformation rules are processed, this would be a rule type of TransformationEventHandler, so you would have to put your Extender Rule code into a TransformationEventHandler, where you filter on this particular condition:
If args.IsBeforeEvent _ AndAlso args.OperationName = BREventOperationType.Transformation.ParseAndTrans.ProcessTransformationRules Then ' -- do your stuff just before transformation rules are processed -- End If
However there are two items to be careful about:
- I would be very wary about dynamically updating Transformation rules on the fly (as the question suggests) from a BR that is triggered just before the transformation rules get processed. Remember this is a multi-user and multi-threaded environment. What if multiple users are performing loads at the same time, and the rule is running concurrently for different users each with different data?
- Note that some Marketplace solutions, such as Transaction Matching (TXM) put their own TransformationEventHandler into the application, so be sure you are not interfering with that if you are using the TXM solution.
@ChrisLoran I assume that for every transformation, the transformation event handler business will be called.
How do i filter that it runs only for specific workflow profile ?
I was able to write that
Dim objTransformer As Transformer = DirectCast(args.Inputs(0), Transformer)
Brapi.ErrorLog.LogMessage(si,"objTransformer.WorkflowProfile.Name=" & objTransformer.WorkflowProfile.Name.ToString)
*looks like we were both typing an answer at the same time*
For every transformation process , yes the transformation event handler will be called, but not for every transformation (as in each data row).
So the Transformation Event Handler may be run concurrently if multiple users are performing import processes.
To filter only specific workflow profile, you can get the name of the workflow profile using the Transformer class instance, which is supplied in args.Inputs(0).
If args.IsBeforeEvent _ AndAlso args.OperationName = BREventOperationType.Transformation.ParseAndTrans.ProcessTransformationRules Then ' -- do your stuff just before transformation rules are processed -- Dim objTransformer As Transformer = DirectCast(args.Inputs(0), Transformer) brapi.ErrorLog.LogMessage(si, args.OperationName & ", ProfileName=" & objTransformer.WorkflowProfile.Name) End If
For filtering only certain workflows, it's better to test the Text property of a workflow profile , rather than hard-code the profile name into rules.
These answers are not an endorsement of dynamically modifying transformation rules on the fly.
Any updates to transformation rules, should be protected by being enclosed within a SyncLock statement to ensure multiple parallel threads do no try to perform updates at the same time.