Computed activity fields

I want to capture the first value from multi-value field available in device_info.

lets say my test fit file column have multi value like these:

70
69

either using device_info.field or device_info.field[0], always gives me 69, I need to pull 70, any ideas?

thanks

You need to tick the ā€œProcessed fit file messagesā€ box and use a script:

{
  let level
  for (let di of icu.fit.device_info) {
    if (di.manufacturer?.value !== 23 /* Suunto*/) continue
    console.log("di " + di)
    let v = di.battery_level?.value
    if (typeof v === 'number' && (!level || v < level)) level = v
  }
  level
}

In this case I have chosen the lowest value. The console log looks like this:

di timestamp(s)=1075909291,battery_voltage(V)=4.05078125,battery_level(%)=70,manufacturer=23,product=59,product_name=Suunto Vertical
di timestamp(s)=1075909479,battery_voltage(V)=4.05078125,battery_level(%)=69,manufacturer=23,product=59,product_name=Suunto Vertical
di timestamp(s)=1075912229,battery_voltage(V)=4.03125,battery_level(%)=68,manufacturer=23,product=59,product_name=Suunto Vertical
1 Like

Yay… Wrote my 1st Java Script :stuck_out_tongue:

Screenshot 2024-02-28 at 10.05.26 AM

5 Likes

Hi.
I would like to keep track on duration of specific intervals during the season.
After my ride I will change the interval name with one that will be the same for every activity with this kind of ā€œtestā€.
Can a custom field be created with this information?
so when I edit the label for this interval, the script searches into all the intervals and if find the ā€œtesting_intervalā€ labeled interval, put this value in the custom field
something like this pseudo code

{
 let output
 for_every_intervals_in_activity as interval{
   if (interval.label == "testing_interval") {
         output = interval.duration
  }
 output
}

thanks!!

Yes you can do that with a computed activity field:

{
    let duration
    for (let iv of activity.icu_intervals) {
        if (iv.label === 'Test') {
            duration = iv.elapsed_time
            break
        }
    }
    duration
}

The fields on interval are listed here.

thanks, it works!
any way to automatically run the script after I edit the interval label? or a button to run this script?
tnx!

If you re-analyze the activity the script will run (Actions → Re-analyze, tick the ā€œKeep Intervalsā€ box!)

1 Like

Hi, I’m trying to set an activity custom field that calculates the days since the last activity tagged with an specific tag. Do you think there is a way to do it with this limitation of not having access to previous activity records?

Not that I can think of. I will get that done eventually.

I am having trouble using the Activity Power Meter custom activity field.
I get the error ā€œUnsupported file type: nullā€

I’ve tried other custom fields and I get the same issue.

I’m definitely using a fit file:
2025-08-07-053647-ELEMNT_BOLT_B8E9-53-020250807-47707-hvjk80.fit

Is there anything obvious I’m missing?

Did you check the ā€˜Processes Fit File messages’ box?

Yes I have the ā€˜Processes Fit File messages’ checked

@david @eva
I think there must be another bug with processing fit files and writing these as string.
Old variables are working:

But if I press the play button it doesn’t work. And it doesn’t work with newly added field neither, like OP said:

1 Like

I am using this field. and when I press ā€œPLAYā€ nothing comes out except what you see below screenshot.

weird thing is -
I am actually getting the correct value/data
Screenshot 2025-08-12 at 3.27.08 PM

I’ve even tried @david 's HR Monitor activity field and I’m getting the error:

ā€œUnsupported file type: nullā€

I’m using a Wahoo ELEMNT Bolt 3 and the fit file

This is error I get in the browser:


This is fixed now, tx for the report.

Your activities are from the Strava API and Strava doesn’t hand over the original files. So there is no fit file to process. We will fix that error message.

You should connect your Wahoo directly so Intervals.icu gets the fit file. Keep Strava connected so the two are linked. You can use the ā€œImport All Strava dataā€ button in the Strava box in /settings to get original files for all of your Strava stuff.

2 Likes

Hi all,

In order to monitor improvements in my running dynamics, I’m plotting ground contact time (GCT) on a custom fitness page (I guess I can because I have a GCT custom field set up for my running activities). However I think that it’s not very relevant to track changes in the average GCT of each running activity, as this average number is affected by slow phases (warmup, recovery, cooldown).

Actually, what would really make sense would be to calculate and show the GCT average taking into account only parts of the activity where the intensity is above a specified value (i.e : tracking GCT only for intervals where my pace is above XXmin/km). This way plotting this ā€˜custom’ GCT over time would really make sense to track progress.

I believe this should be possible to create a new custom stream that does this, but I really don’t know how to code it… If it’s to complicated, retrieving the max 5min value (as it’s done already for power) could also work I guess, although less practical.

Could someone please help me out with this? Thanks!

I think you don’t need a new custom stream. You need a new custom field:

  1. Filter your GCT stream if pace is > threshold
  2. calculate the average over all filtered values
1 Like

MedTechCD has a Custom Field that identifies activity periods with specified speed power and hr ranges Z2RunCad, that you can easily modify for GCT

Thanks for that, exactly the piece of code I was looking for to get started!
I’ve been trying to set up any of the existing Z2runXX custom activity fields, but none work (they all give me the same TypeError: Cannot read property ā€œdataā€ from null message when I try to run a preview for the script page). @MedTechCD, any idea of what could be wrong? I tried out re-analysing the activity, using bigger ranges, lowering the minimum number of point threshold, and so on without success…).

I’m sure it’s the way to go, but I’m really struggling here!

Thanks again for your help!