Exemplo n.º 1
0
        private PXAction AddAction(PXGraph graph, Survey survey, string fieldName)
        {
            PXButtonDelegate handler = (PXAdapter adapter) => {
                string str1        = (string.IsNullOrEmpty(adapter.CommandArguments) ? graph.PrimaryView : adapter.CommandArguments);
                string primaryView = graph.PrimaryView;
                var    surveyID    = survey.SurveyID;
                var    caches      = Base.Caches;
                var    cache       = caches[typeof(EDoc)];
                var    doc         = cache?.Current;
                var    entityType  = cache?.GetItemType();
                var    noteID      = PXNoteAttribute.GetNoteIDIfExists(cache, doc);
                fieldName = Clean(fieldName);
                var contactID   = (int?)cache?.GetValue(doc, fieldName);
                var surveyGraph = PXGraph.CreateInstance <SurveyMaint>();
                if (survey != null && contactID.HasValue && noteID.HasValue)
                {
                    surveyGraph.Survey.Current = survey;
                    var user      = surveyGraph.InsertOrFindUser(survey, contactID, false);
                    var collector = surveyGraph.DoUpsertCollector(survey, user, noteID, true, false);
                }
                return(adapter.Get());
            };
            var actionName  = ACTION_PREFIX + survey.SurveyID;
            var displayName = survey.Title; // TODO Add " -> Ship-To Contact"

            return(AddAction(actionName, displayName, handler));
        }