'Dealing with 'cannot be resolved to a variable' in Drools

I have the following rule

rule fpf_mdd_music_dans_drama salience 180
when
    $reslist : List(size > 0) from collect (NvbQueryResults(control() in ("fpf_mdd_music_dans_drama_p1",
                                                                           "fpf_mdd_music_dans_drama_p2")))                                                                                
    $qr : NvbQueryResults(control()== "fpf_mdd_r94_upf")
then
    res = (NvbQueryResults)$reslist.get(0);
    insert(new NvbQueryResults("fpf_mdd_music_dans_drama",res.count() + $qr.count()));
end

The NvbQueryResults looks like this

case class NvbQueryResults(control: String, count: Int = 0)

my problem is that I get this error when I try to run the rule

Rule Compilation error : [Rule name='fpf_mdd_music_dans_drama']
res cannot be resolved to a variable
res cannot be resolved

I don't understand what is wrong, can someone please explain to me me the problem.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source