Divide a field by a number in ruby

Good, I need help please, I need to divide a number by 1000 using the ruby filter, could you help me with the code of that? I am really a beginner, I have something like this:

ruby {
code => "event.set('timetaken', event.get('valor') / event.get('1000'))"
}

I know that is wrong, since it gives me "Ruby exception occurred: undefined method` / 'for "187": String "error, the truth is that I could not find the syntax, please help

Thank you so much

The error message indicates [valor] is a string, so you need to convert it to a number. You could try

code => "event.set('timetaken', event.get('valor').to_f / 1000)"

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.