Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8832

Save/Update a Field property programmatically

$
0
0
Hi all,I created a Custom Scheduled Task that connects to an API and gathers some data, periodically, among which the Caption and ValidationErrorMessage for given fields of a form. Now, ther reasons I must do it are a lot, I don't want to get in details. That said, I tried to find documentation on how to save a property programmatically and I'm still not able to.Currently, the core part of my code that should update a field given his formfieldname looks like this:private void SetFormFieldText(string formfieldname, string caption_text, string validation_text) { BizFormInfo formObject = BizFormInfoProvider.GetBizFormInfo(@MyCustomForm@, SiteContext.CurrentSiteID); DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(formObject.FormClassID); if (dci != null) { FormInfo fi = new FormInfo(dci.ClassFormDefinition); if(fi != null) { FormFieldInfo ffi = fi.GetFormField(formfieldname); if (ffi!=null) { ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption,caption_text); ffi.SetPropertyValue(FormFieldPropertyEnum.ValidationErrorMessage,validation_text); fi.UpdateExistingFields(fi); //saving? //fi.UpdateFormField(formfieldname,ffi); //tryed this, too } } } } but neither using UpdateExistingFields or UpdateFormField (that I'm sure are reached and executed) I can trig the saving of those set properties. Using SQL Profiler, I can't see any update on the DB at all.What's the right way to save changes made on a custom form using SetPropertyValue on a field, programmatically?I'm using Kentico 9.Thanks, Fabio

Viewing all articles
Browse latest Browse all 8832

Trending Articles