[Progress Communities] [Progress OpenEdge ABL] Forum Post: RE: Choices field in OData services returning position instead of value

  • Thread starter Thread starter jread
  • Start date Start date
Status
Not open for further replies.
J

jread

Guest
I have used a calculated property to alleviate the need for conversion of binary in JS. Here is a CalculatedPropery class you can add to your web service following the instructions here: Here is the class (Replace 'Features' with your property name): using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Web; using Telerik.Sitefinity.Data; using Telerik.Sitefinity.DynamicModules.Model; using Telerik.Sitefinity.Model; using Telerik.Sitefinity; using Telerik.Sitefinity.Web.Services.Extensibility; namespace SitefinityWebApp.Helpers { public class CustomChoicesCalculatedField : CalculatedProperty { /// /// What type of data is being returned, must be a simple type or something that is already in the service or marked with [DataContract] /// public override Type ReturnType { get { return typeof(ChoiceOption[]); } } /// /// Returns Choice option for Choices fields on the Jobs Dynamic Module /// /// Data beeing returned by the oData service /// Current Manager from the service /// public override IDictionary GetValues(IEnumerable items, IManager manager) { var ret = new Dictionary (); foreach (IDataItem item in items) { var dynamicContent = item as DynamicContent; var choices = dynamicContent.GetValue ("Features"); if (choices != null) { ret.Add(item, choices); } } return ret; } } } link to GIST: This Calculated field is intended to return the string values of a choices field on a content item. Follow instructions here to add the property to your web service. You will need to replace 'Features' with your Property name. https://www.progress.com/documentation/sitefinity-cms/for-developers-custom-calculated-properties

Continue reading...
 
Status
Not open for further replies.
Back
Top