CodeEffects规则引擎:评估规则中+运算符的使用方法
Got it, let's break down exactly how to create that rule where you sum multiple calls to your somefunc custom function and check if the total is greater than 1. Here's a step-by-step guide tailored to the CodeEffects editor:
Prerequisite Check
First, make sure your somefunc custom function is properly registered with the CodeEffects engine. It needs to return a numeric type (like int, decimal, or double)—the editor only allows the + operator for operands that can be mathematically added. If you haven't set this up yet, double-check your function's return type in your engine configuration.
Step-by-Step Rule Creation
- Open the CodeEffects Rule Editor and create a new Evaluation Rule (this is the right rule type for yes/no judgment scenarios like yours).
- In the rule's condition panel, click to add a new condition. Select the Compare Values condition type.
- Build the left-hand operand (the sum of your function calls):
- Start by selecting your
somefuncfrom the function list, then picksomevar1as its input parameter. This addssomefunc(somevar1)to the operand area. - Click the Add Operator button (looks like a
+icon in most editor themes) and choose the+arithmetic operator. - Repeat the first step: add
somefuncagain, selectsomevar2as the parameter. - Add another
+operator, then addsomefuncwithsomevar3as its parameter.
- Start by selecting your
- Set the comparison operator to Greater Than.
- For the right-hand operand, simply enter the numeric value
1.
Final Rule Structure
Once you're done, your rule will look something like this in the editor's text view:
If (somefunc(somevar1) + somefunc(somevar2) + somefunc(somevar3)) > 1 Then // Define your action here (e.g., mark as "Eligible" or trigger a workflow) End If
Quick Troubleshooting Tip
If the + operator doesn't show up when you try to add it, double-check two things:
- Your
somefuncreturns a numeric type (not a string or boolean). - You're adding the operator between valid operands (not directly after a parameter or before a function call).
内容的提问来源于stack exchange,提问作者Satya

