Exemple #1
0
        private PXFieldState CreateFieldStateForFieldName(object returnState, Type type)
        {
            List <string> allowedValues = new List <string>();
            List <string> allowedLabels = new List <string>();

            Dictionary <string, string> fields = new Dictionary <string, string>();

            foreach (var field in PXCache.GetBqlTable(type)
                     .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                     .SelectMany(p => p.GetCustomAttributes(true).Where(atr => atr is PXMassMergableFieldAttribute), (p, atr) => p))
            {
                PXFieldState fs = this.Caches[type].GetStateExt(null, field.Name) as PXFieldState;
                if (!fields.ContainsKey(field.Name))
                {
                    fields[field.Name] = fs != null ? fs.DisplayName : field.Name;
                }
            }

            foreach (var item in fields.OrderBy(i => i.Value))
            {
                allowedValues.Add(item.Key);
                allowedLabels.Add(item.Value);
            }

            return(PXStringState.CreateInstance(returnState, 60, null, "FieldName", false, 1, null,
                                                allowedValues.ToArray(), allowedLabels.ToArray(), true, null));
        }