public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); if (sender.Graph.PrimaryItemType == null) { return; } PXButtonDelegate delgate = delegate(PXAdapter adapter) { PXCache cache = adapter.View.Graph.Caches[typeof(SOOrderShipment)]; if (cache.Current != null) { var helper = new EntityHelper(cache.Graph); object val = cache.GetValueExt(cache.Current, _FieldName); var state = val as PXRefNoteBaseAttribute.PXLinkState; if (state != null) { helper.NavigateToRow(state.target.FullName, state.keys, PXRedirectHelper.WindowMode.NewWindow); } else { helper.NavigateToRow((Guid?)cache.GetValue(cache.Current, _FieldName), PXRedirectHelper.WindowMode.NewWindow); } } return(adapter.Get()); }; string actionName = $"{ sender.GetItemType().Name }~{ _FieldName }~Link"; PXNamedAction.AddHiddenAction(sender.Graph, sender.Graph.PrimaryItemType, actionName, delgate); }
public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); PXButtonDelegate del = delegate(PXAdapter adapter) { PXCache cache = adapter.View.Graph.Caches[typeof(SOLineSplit)]; if (cache.Current != null) { object val = cache.GetValueExt(cache.Current, _FieldName); PXLinkState state = val as PXLinkState; if (state != null) { helper.NavigateToRow(state.target.FullName, state.keys, PXRedirectHelper.WindowMode.NewWindow); } else { helper.NavigateToRow((Guid?)cache.GetValue(cache.Current, _FieldName), PXRedirectHelper.WindowMode.NewWindow); } } return(adapter.Get()); }; string ActionName = sender.GetItemType().Name + "$" + _FieldName + "$Link"; sender.Graph.Actions[ActionName] = (PXAction)Activator.CreateInstance(typeof(PXNamedAction <>).MakeGenericType(typeof(SOOrder)), new object[] { sender.Graph, ActionName, del, new PXEventSubscriberAttribute[] { new PXUIFieldAttribute { MapEnableRights = PXCacheRights.Select } } }); }
public SOOrderMaint() { PXButtonDelegate actionHandlerSimple = adapter => { MethodWhichInitializeAnotherGraph(adapter); return(adapter.Get()); }; Actions.Add("ActionSimple", new PXNamedAction <SOOrder>(this, "ActionSimple", actionHandlerSimple)); PXButtonDelegate actionHandlerParenthesized = (adapter) => { MethodWhichInitializeAnotherGraph(adapter); return(adapter.Get()); }; Actions.Add("ActionParenthesized", new PXNamedAction <SOOrder>(this, "ActionParenthesized", actionHandlerSimple)); PXButtonDelegate actionHandlerDelegate = delegate(PXAdapter adapter) { MethodWhichInitializeAnotherGraph(adapter); return(adapter.Get()); }; Actions.Add("ActionDelegate", new PXNamedAction <SOOrder>(this, "ActionDelegate", actionHandlerDelegate)); // Simple case with no recursive code analysis involved Orders.SetProcessDelegate(list => { var graph = PXGraph.CreateInstance <SOOrderMaint>(); }); }
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)); }
private PXAction AddAction(string actionName, string displayName, PXButtonDelegate handler) { var action = PXNamedAction <EDoc> .AddAction(Base, actionName, displayName, handler); SurveyFolder.AddMenuAction(action); return(action); }
protected PXAction AddAction(PXGraph graph, string name, string displayName, PXButtonDelegate handler) { PXUIFieldAttribute uiAtt = new PXUIFieldAttribute { DisplayName = PXMessages.LocalizeNoPrefix(displayName), MapEnableRights = PXCacheRights.Select }; List <PXEventSubscriberAttribute> addAttrs = new List <PXEventSubscriberAttribute> { uiAtt }; PXNamedAction <Primary> res = new PXNamedAction <Primary>(graph, name, handler, addAttrs.ToArray()); graph.Actions[name] = res; return(res); }