         
         // store it in local cache so it will get updated to Bridge next time
         SBAClientDataProfileItem.addToCurrentValues(whatAndWhen.cachedDictionaryRepresentation(), forProfileKey: profileKey)
+    }
+    
+    open func setValue(_ newValue: Any?, asOf when: Date, to scheduledActivity: SBBScheduledActivity) {
+        guard let jsonValue = commonItemTypeToJson(val: newValue) else { return }
+        
+        let whatAndWhen = SBAWhatAndWhen(jsonValue, asOf: when as NSDate)
+        
+        // store it to the specified scheduled activity's clientData
+        setTo(scheduledActivity, jsonWhatAndWhen: whatAndWhen.dictionaryRepresentation())
     }
     
     open func valuesAndDates() -> [SBAWhatAndWhen] {

            bestActivity.startedOn = when
        }
        
        let clientData = bestActivity.clientData as? NSMutableDictionary ?? NSMutableDictionary()
        var jsonWhatsAndWhens = clientData[sourceKey] as? [[String: SBBJSONValue]] ?? [[String: SBBJSONValue]]()
        jsonWhatsAndWhens.append(jsonWhatAndWhen)
        
        // make sure the jsonWhatsAndWhens are in ascending order by date
        jsonWhatsAndWhens = SBAClientDataProfileItem.jsonWhatsAndWhensSortedByWhen(jsonWhatsAndWhens)
        clientData[sourceKey] = jsonWhatsAndWhens
        bestActivity.clientData = clientData
        
        if  bestActivity.finishedOn == nil || when > bestActivity.finishedOn! {
            bestActivity.finishedOn = when
        }

        // add the found SBBScheduledActivity to the set of those that need to be updated to Bridge
        SBAClientDataProfileItem.toBeUpdatedToBridge.insert(bestActivity)
    }
    
    open func setStoredValue(_ newValue: Any?, asOf when: Date) {



/**
 The activity to which an SBAClientDataProfileItem is attached should be scheduled such that there is always an appropriate
 SBBScheduledActivity object on which to save it (i.e. doesn't expire before being rescheduled). Its clientData must also be
 a JSON dictionary, and the values set here will be stored at the top level by sourceKey as a list of dictionaries containing
 "date" and "value" entries. If the value of the item is changed more quickly than it is rescheduled, the "date" timestamp
 allows there to be more than one entry per SBBScheduledActivity instance, so this type of profile item can be used to record
 and/or retrieve a time series of values.
 */
open class SBAClientDataProfileItem: SBAProfileItemBase {
    // ClientData profile items are attached to and read from the most date-appropriate instance
