NetXMS Support Forum

English Support => General Support => Topic started by: Nikk on March 24, 2014, 05:35:59 PM

Title: Value formatting
Post by: Nikk on March 24, 2014, 05:35:59 PM
Hi,

How can i get clean formatted value in last value window (or better as event parameter)? What I want to do is format or round disk space value.
The value shows up like 12.410000 , but it should be like 12.41 (as it shows in history table)  because transformation script is: format($1,1,2) or round($1,2).

And event parameter %4 is also taking those zeros. How can I get rid of those zeros?

Nikk
Title: Re: Value formatting
Post by: Victor Kirhenshtein on March 25, 2014, 07:32:10 PM
Hi!

You can format event parameter using script, like this:

1. use %[formatted_p4] instead of %4

2. Create script named formatted_p4 in library like this:

return format($event->parameters[4], 1, 2);

Best regards,
Victor
Title: Re: Value formatting
Post by: Nikk on March 31, 2014, 10:09:41 AM
Thank you, Victor! Works great :)
Title: Re: Value formatting
Post by: Shebarn on December 10, 2019, 09:42:54 AM
I have the same problem with voltage return as float.

My Transformation looks like this normally:

return $1/10;

(since the value returned is always 10x the actual voltage value)

But this always gives me a value of i.e. 23.500000

return format($1/10, 1, 1) gives the right value when I test it at transformation but not when the alarm is raised.

I tried Victor's solution of script:

Script Name: retvolt
Script Content: return format($event->parameters[1]/10, 1, 1);

At transformation I then put: return $[retvolt];

I get error: Error 34 in line 1: Function or operation argument is not a container

I assume I am calling the script the wrong way, but can't find examples of how to do it otherwise?
Please help.
Title: Re: Value formatting
Post by: Shebarn on December 10, 2019, 10:46:10 AM
Ok, figured it out.

Used the script in the message of the event's event configuration and it worked perfect...