Ad Widget

Collapse

Multiple items preprocessing with JavaScript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Crororo
    Junior Member
    • May 2021
    • 1

    #1

    Multiple items preprocessing with JavaScript

    Perhaps it will be useful to someone. I tried to find a ready-made solution but couldn't.

    I needed to make a table conversion of two values - first ranged 0...999 and second 0.00...9.99 and I decided to use JavaScript preprocessing for this. But here's the bad luck - only one value can be passed to the script - the value of the current item. I solved the problem as follows:
    1. Created a new item with the calculated type.
    2. I added to the formula
    Code:
    (last("host:item1") * 100000) + last("host:item2")*100
    As result we will have value=73300748 for example
    3. Already in the javascript itself, I decomposed the value obtained above into two that I need:
    Code:
    value = value.toString();
    value_pr1 = parseInt(value.slice(0, 3));
    value_pr2 = parseInt(value.slice(4, 10));
    Et voila - both items are available in javascript code.
Working...