I have a rule which take a String type input parameter. Can I remove the whitespaces from the value this parameter holds using BAL.
If not what is the other option to do this. In this JRule there is a decision table where condition column is this parameter and then output is action column.
Say you define Rulset Paramter "Name" of type String for Rule IsDepartmentManager where output ruleset parameter is boolean.
Now in the decision table the values in Name column is say "John" and out for this is True. Otherwise False.
Now when this rule is invoked as web-service the input send is "John ". As the name contains white spaces and the decision table do the exact matching, the result return is False.
You can add an Initial Action in your Rule Task (that contains the Decision Table or the rule) in which you can execute theInputString.trim();
Can you post an example of the rule? It would be good to see why you need to trim the string in the first place.
But you could write a function to do this and expose it via the BOM. This can be done two ways. First, you could write a virtual function directly in the BOM that takes a string and trims it. The second option if you use Java XOM's is to write the function in Java and expose that via the BOM.
If your using the virtual function approach, then the code will be written using IRL, but this is essentially a cut down version of Java so it will have the String object methods needed to trim. For example:
To add a BOM function, do the following steps:
Once you have done this, you should then be able to see the new method in the BAL editor for the rule.
However, what I would say is that you should try and trim and prepare the data before passing it into the rule set. Ideally you want a little custom functions in the rule set as possible to keep the rules as clean as possible.