private Guid?FindMatchingNoteIDForFolder(string screenID, string keyValues)
        {
            string graphType = PXPageIndexingService.GetGraphTypeByScreenID(screenID);

            if (string.IsNullOrEmpty(graphType))
            {
                throw new PXException(Messages.PrimaryGraphForScreenIDNotFound, screenID);
            }

            string primaryViewName = PXPageIndexingService.GetPrimaryView(graphType);

            if (string.IsNullOrEmpty(primaryViewName))
            {
                throw new PXException(Messages.PrimaryGraphForScreenIDNotFound, graphType);
            }

            var viewDescription = new Data.Description.PXViewDescription(primaryViewName);

            KeyValuePair <string, string>[] keyValuePairs;
            var graph = PXGraph.CreateInstance(PXBuildManager.GetType(graphType, true));

            try
            {
                keyValuePairs = GetKeyValuePairsFromKeyValues(graph, primaryViewName, keyValues);
            }
            catch (FolderNameKeyValuesMismatchException)
            {
                return(null);
            }

            var view = graph.Views[primaryViewName];

            ScreenUtils.SelectCurrent(view, viewDescription, keyValuePairs);

            if (view.Cache.Current == null)
            {
                return(null);
            }
            else
            {
                return(PXNoteAttribute.GetNoteID(view.Cache, view.Cache.Current, EntityHelper.GetNoteField(view.Cache.Current.GetType())));
            }
        }
        protected virtual void BoxScreenConfiguration_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            var screenConfig = e.Row as BoxScreenConfiguration;

            if (!string.IsNullOrEmpty(screenConfig.ScreenID))
            {
                string graphTypeName = PXPageIndexingService.GetGraphTypeByScreenID(screenConfig.ScreenID);
                if (string.IsNullOrEmpty(graphTypeName))
                {
                    throw new PXException(Messages.PrimaryGraphForScreenIDNotFound, screenConfig.ScreenID);
                }
                Type graphType = PXBuildManager.GetType(graphTypeName, true);
                var  graph     = PXGraph.CreateInstance(graphType);

                string primaryViewName = PXPageIndexingService.GetPrimaryView(graphTypeName);
                PXView view            = graph.Views[primaryViewName];

                //Construct ddl values and displayed values, specifying field name for duplicates
                var fieldsArray  = PXFieldState.GetFields(graph, view.BqlSelect.GetTables(), true);
                var displayNames = fieldsArray.GroupBy(fa => fa.DisplayName).ToDictionary(k => k.Key, v => v.ToList());
                var labels       = new List <string>();
                var values       = new List <string>();
                foreach (var displayName in displayNames)
                {
                    if (displayName.Value.Count > 1)
                    {
                        foreach (var displayNameField in displayName.Value)
                        {
                            labels.Add($"{displayName.Key} ({displayNameField.Name})");
                            values.Add(displayNameField.Name);
                        }
                    }
                    else
                    {
                        labels.Add(displayName.Key);
                        values.Add(displayName.Value.FirstOrDefault()?.Name);
                    }
                }

                PXStringListAttribute.SetList <BoxScreenGroupingFields.fieldName>(Fields.Cache, null, values.ToArray(), labels.ToArray());
            }
        }
예제 #3
0
        private static bool ScreenPrimaryViewSupportsAttachments(PXGraph graph, string screenID)
        {
            string graphType = PXPageIndexingService.GetGraphTypeByScreenID(screenID);

            if (string.IsNullOrEmpty(graphType))
            {
                return(false);
            }

            string primaryViewName = PXPageIndexingService.GetPrimaryView(graphType);

            if (string.IsNullOrEmpty(primaryViewName))
            {
                return(false);
            }

            PXViewInfo view = GraphHelper.GetGraphView(graphType, primaryViewName);

            if (view == null)
            {
                return(false);
            }

            PXCache cache = graph.Caches[view.Cache.CacheType];

            if (cache == null)
            {
                return(false);
            }

            foreach (System.Reflection.PropertyInfo prop in cache.GetItemType().GetProperties())
            {
                if (prop.IsDefined(typeof(PXNoteAttribute), true))
                {
                    return(true);
                }
            }

            return(false);
        }