Search code examples
krl

Getting a "Can't use an undefined value as an ARRAY reference" error in my KRL code


When I run my Kynetx app I am getting the following error:

Can't use an undefined value as an ARRAY reference at /web/lib/perl/Kynetx/Persistence.pm line 284, <GEN0> line 465. 

My code looks like the following:

rule page_loaded is active {
  select when pageview "manticore.*" setting()
  pre {
    savedName = current ent:userName;
  }
  if (savedName neq "") then {
    notify("Hello #{savedName}!!","Welcome back!") with sticky = true;
  }
  notfired {
    raise explicit event name_not_saved_yet;
  }  
}  

I had this code working before, not sure what is killing it now.

UPDATE: From the debug information.

// 2010/12/07 16:45:31 DEBUG Scheduler.pm a57x4 clear_saved_name Schedule iterator returning email_client with current RID count 0 and current rule count 3
// 2010/12/07 16:45:31 DEBUG Rules.pm a57x4 email_client Rule email_client is active
// 2010/12/07 16:45:31 DEBUG Rules.pm a57x4 email_client [selected] email_client
// 2010/12/07 16:45:31 DEBUG Rules.pm a57x4 email_client
//------------------- begin rule execution: email_client ------------------------
// 2010/12/07 16:45:31 ERROR Rules.pm a57x4 email_client Ruleset a57x4 failed: Can't use an undefined value as an ARRAY reference at /web/lib/perl/Kynetx/Persistence.pm line 284, <GEN0> line 6. 

Solution

  • We changed the way that we store trails. I will put a bug fix in asap.

    If I show you some secret functionality, you need to promise not to tell

    for your entity variable try the syntax (if you have a variable myUserName):

     set ent:userName myUserName
    

    Then, for your example, you could write:

    pre {
      savedName = ent:userName || "";
    }
    if (savedName neq "") then ....
    

    I will update this answer when we release a fix