         
         // 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] {

        super.init()
    }
    
    public init(_ value: SBBJSONValue, asOf date: NSDate, isNew:Bool) {
        self.value = value
        self.date = date
        self.isNew = isNew

            bestActivity.startedOn = when
        }
        
        setTo(bestActivity, jsonWhatAndWhen: jsonWhatAndWhen)
    }
    
    func setTo(_ scheduledActivity: SBBScheduledActivity, jsonWhatAndWhen: [String: SBBJSONValue]) {
        let when = SBAWhatAndWhen(dictionaryRepresentation: jsonWhatAndWhen).date as Date
        let clientData = scheduledActivity.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
        scheduledActivity.clientData = clientData
        
        if  scheduledActivity.finishedOn == nil || when > scheduledActivity.finishedOn! {
            scheduledActivity.finishedOn = when
        }

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