DataFiled discard activity

Hi,
In my DataField I store values in Properties/Settings ,see below


BUT if the user DISCARDS the Activity I do NOT want to save the Property!
How can I achieve this?


I am missing an event like onTimerDiscard(). Or can I use something like OnSessionSave() asking discard()  ??

This will be used for adding the distance and altitude over a longer timer.

see https://apps.garmin.com/en-US/apps/1cc6cbe8-d655-4956-b870-54eea8bf9c6d


 {

function onTimerStop() 
	{
		var propSum = Application.Properties.getValue("propSum1Altitude");
		propSum = Math.round(propSum + myTotalAscent);
	    Application.Properties.setValue("propSum1Altitude", propSum);
	}
	
function onTimerStart() // used on resume button on watch
	{
		var propSum = Application.Properties.getValue("propSum1Altitude");
		// remove myTotalAscent set before on stop, otherwise it would count double onResume	
		propSum = Math.round(propSum - myTotalAscent);
	    Application.Properties.setValue("propSum1Altitude", propSum);  
	 }


Thanks
Marcel 

  • I'm not sure there's a way to tell the difference between a save and discard in a DF. 

    onTimerStop() doesn't really mean the end of an activity, as I'm pretty sure it happens with a manual pause. Per the API doc, onTimerPaused() occures for auto-pause,  You might want to try onTimerReset() instead.

    Unless you have settings for "propSumAltitude", you also may want to use Storage instead of Properties.