I need to write a custom function that does some checks on the facts in drools working memory and returns a number.
As far as I've figured out - I need to import the helper class which has the custom function.
Now how to access the working memory from the function? And how would I call that function in the LHS?
Functions can't actually access the working memory. You could bind the required facts in your rule and then send them as parameters to your function.
A better approach would be to use a Query instead of a function. You can read more about queries in Drools' documentation: http://docs.jboss.org/drools/release/6.3.0.Beta1/drools-docs/html_single/index.html#QuerySection