How to update a BPL proces using business rule.
Initial questions have been answered. Expanded the post with actual code (see below)
So, I'd like to update one (and preferably) more context-fields in my ensemble BPL business process based upon the information in the request that initiates said BPL proces. I got a few questions about that:
1. First, I can't get it to work. Specifically, in the BPL process I call the business rule with my request as context and expect it to put it results in context.Boolean. The business rule nicely updates the context.Boolean but the conditional logic looks at specific fields in the request (i.e. if request.MyField="helloworld" then return true otherwise return false) doesn't work: The business rule always returns false. I suspect that the syntax I use in the conditional isn't entirely correct. (i.e. I am trying 'request.MyField = "helloworld").
2. Is it somehow possible to use one business rule to update multiple context fields in a BPL process? For instance, by trying to assign context.Boolean = true instead of returning true?
3. I could also solve this issue by implementing a Lookup Table or with a data transformation, but I have the feeling that a business rule is the nicest way to solve this particular problem. Are there any best practies when to use either a look up table, a data transformation, or a business rule?
Edit:
Okay, so let's work out what I am trying to achieve. I have a business process which receives an EventCode in the request message. Based on the EventCode I need to determine whether I need to create a Case (via a business operation) and I need to add the description of the EventCode to that call. There are a total of 150 EventCodes. Now, our business finds it challenging to determine which event code should result in a call and which one shouldn't. Therefore I expect to continuously review the list of codes together with the business while testing the implementation.
So what I have done so far is to add two context variables to my process:
- context.CreateCall As %Boolean to determine whether I should send a call.
- context.EventDescription As %String to write the description in the call.
Now, what I want to do is to transform request.EventCode to context.CreateCall and context.EventDescription, but I want to do it in such I way that I keep an overview of what I do with which event code and that I can discuss this overview with the business. I have the feeling that business rules are best suited for this. In my eyes a data transformation won't give me the overview and with a Look Up table i'll end up with two tables (again no overview).
So I am trying to configure my Business Process and rule. I want the rule to use the EventCode from the request message and then fill the context fields of the BPL process. However, as far as I can see the condition "request.EventCode=2103" doesn't trigger even though the EventCode is set to 2013 for a process. Please find the code below:
This is the code of my business rule:
<ruleSet name="" effectiveBegin="" effectiveEnd="">
<rule name="Assess Event Code" disabled="false">
<when condition="request.EventCode="2103"">
<assign property="context.CreateCase" value="true"></assign>
<assign property="context.EventDescription" value=""Test message""></assign>
</when>
<otherwise>
<assign property="context.CreateCase" value="false"></assign>
<assign property="context.EventDescription" value=""Unknown event code""></assign>
</otherwise>
</rule>
</ruleSet>
</ruleDefinition>
And a snippet from the Business Process calling the rule:
<context>
<property name='CreateCase' type='%Boolean' initialexpression='0' instantiate='0' />
<property name='EventDescription' type='%String' instantiate='0' >
<parameters>
<parameter name='MAXLEN' value='2500' />
</parameters>
</property>
</context>
..
<rule name='Fire Rule' rule='CareHome.DetermineEventFollowUp' resultLocation='context' ruleContext='request' xpos='200' ypos='350' >
</rule>