Set/get CustomAttribute issue in v4.3.6

Started by cserzs, May 31, 2023, 02:40:17 PM

Previous topic - Next topic

cserzs

Hi, 

We have upgraded our NetXMS system from v3.9 to v4.3.6 and since then the set and getcustomattribute functions are not working properly. I use these functions in a trap processing script as below:

// fmRadioAlarmState (0:warning event, 1:critical event, 2:alarm ceased)
//m - contains the unique ID of the alarm
  t = time();
  evts = " ON";
  str3 = "";
  switch($event->parameters[2])
  {
      case 0:
        evt = "SME_PIRA_TRAP_WARNING";
        break;
      case 1:
        evt = "SME_PIRA_TRAP_CRITICAL";
        $node->setCustomAttribute(".signalLossTime" . format(m, 1, 0), t);
        break;
      case 2:
      evt = "SME_PIRA_TRAP_CLOSE";
      evts = " OFF";
      t0 = $node->getCustomAttribute(".signalLossTime" . format(m, 1, 0));
      if (t0 != null)
        {
        str3 = "Starting from:" . strftime("%Y.%m.%d %H:%M:%S", t0) . ", duration: " . format((t-t0), 1, 0) . "s";
        }
      break; 
      default:
        evt = "SME_PIRA_TRAP_INFO";
        break;
  }

As I see the main problem is that the getcustomatrribute function always returns null. Anyone have any idea what could be the problem?

Thank you in advance.

Filipp Sudanov

I was not able to replicate this. What kind of ID do you have in m variable, is it decimal number or hex?

I'd try a few things:

- executing this script via "Execute server script" from node context menu. May be you'll see some errors there.
- you can try removing the dot from the beginning of custom attribute name - in this case custom attribute will be visible in node properties. Does setCustomAttribute actually add custom attribute to the node?