NetXMS Support Forum

English Support => General Support => Topic started by: gkaudewitz on November 08, 2023, 04:18:11 PM

Title: Using Scripts in Action Messagetext
Post by: gkaudewitz on November 08, 2023, 04:18:11 PM
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

Title: Re: Using Scripts in Action Messagetext
Post by: Filipp Sudanov on November 08, 2023, 05:14:12 PM
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 (https://www.netxms.org/documentation/nxsl-latest/#class-netobj), Event (https://www.netxms.org/documentation/nxsl-latest/#class-event) or Alarm (https://www.netxms.org/documentation/nxsl-latest/#class-alarm) , e.g.:

$node->expandString("%n")

Title: Re: Using Scripts in Action Messagetext
Post by: gkaudewitz on November 09, 2023, 04:29:50 PM
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
Title: Re: Using Scripts in Action Messagetext
Post by: Filipp Sudanov on November 09, 2023, 05:50:01 PM
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