Using Scripts in Action Messagetext

Started by gkaudewitz, November 08, 2023, 04:18:11 PM

Previous topic - Next topic

gkaudewitz

Within action messsage text it is possible to use the %[name] macro for generating output to message-text. The called funktion can have parameters. That works fine.

The problem I want to solve is:
Who to use the values of other macros as parameter for the function. E.g. %[script/myfunct(%z,%a,%c)] with the values of %z, %a and %c. The first tests I did are resulting in the strings "%z", %a" and "%c" that are passed to called function.

Who can I achieve that values of macros are passed to the function?

Best regards

Goerg


Filipp Sudanov

Nested custom attributes are not supported. But you can get all the data you need within the script, either by using object attributes, e.g.

$node->ipAddr

or by calling expandString method of NetObj, Event or Alarm , e.g.:

$node->expandString("%n")


gkaudewitz

Thanks for the info. That helps me very much, concerning data I want to access within action message text!

But I got an other problem that I don't what goes wrong.

In message text I am calling a function this way %[NMSRV::test/testfkt1("p1","p2","p3","p4")] for test this is a very simple function with this definition in NMSRV::test :

function testfkt1(pm1,pm2,pm3,pm4)
 { retval = "Param1: "..pm1.." Param2:"..pm2.." Param3:"..pm3.." Param4:"..pm4;
  return (retval);
 }


The resulting message differs from expected result. Generated value from this function is:

Param1:  Param2:p1 Param3:p2 Param4:p3

It seems, that there is a shift of parameters when script is called from message text. I tested it with two different installations of NetXMS Version 4.4.3.

Best regards

Georg

Filipp Sudanov

It's a bug, was fixed couple of days ago, if there will be another patch release for 4.4, fix will be there, otherwise it will be in 5.0 which should be out in December