/// <summary> /// Tries to perform a redirect to the original AR or AP document of a given /// <see cref="DRSchedule"/> record. /// </summary> /// <param name="sourceGraph"> /// A graph through which the redirect will be processed. /// </param> /// <param name="scheduleDetail"> /// The <see cref="DRSchedule"/> record containing the document type and /// document reference number necessary for the redirect. /// </param> public static void NavigateToOriginalDocument( PXGraph sourceGraph, DRSchedule schedule) { IBqlTable originalDocument = null; if (schedule.Module == BatchModule.AR) { originalDocument = (ARRegister) PXSelect < ARRegister, Where <ARRegister.docType, Equal <Required <DRSchedule.docType> >, And <ARRegister.refNbr, Equal <Required <DRSchedule.refNbr> > > > > .Select(sourceGraph, schedule.DocType, schedule.RefNbr); } else if (schedule.Module == BatchModule.AP) { originalDocument = (APRegister) PXSelect < APRegister, Where <APRegister.docType, Equal <Required <DRSchedule.docType> >, And <APRegister.refNbr, Equal <Required <DRSchedule.refNbr> > > > > .Select(sourceGraph, schedule.DocType, schedule.RefNbr); } if (originalDocument != null) { PXRedirectHelper.TryRedirect( sourceGraph.Caches[originalDocument.GetType()], originalDocument, "ViewDocument", PXRedirectHelper.WindowMode.NewWindow); } }
private bool IsItemRuleTrue(IBqlTable item, EPAssignmentRule rule) { if (item is EPEmployee && rule.FieldName.Equals(typeof(EPEmployee.workgroupID).Name, StringComparison.InvariantCultureIgnoreCase)) { return(IsEmployeeInWorkgroup((EPEmployee)item, rule)); } currentItem = item; Type viewType = BqlCommand.Compose(typeof(Select <>), item.GetType()); PXView itemView = new PXView(this, false, BqlCommand.CreateInstance(viewType), (PXSelectDelegate)getItemRecord); if (rule.Condition == null) { return(false); } PXFilterRow filter = new PXFilterRow( rule.FieldName, (PXCondition)rule.Condition.Value, GetFieldValue(item, rule.FieldName, rule.FieldValue), null); int startRow = 0; int totalRows = 0; List <object> result = itemView.Select(null, null, null, null, null, new PXFilterRow[] { filter }, ref startRow, 1, ref totalRows); return(result.Count > 0); }
//Refactor - Generalize if possible!!! private IBqlTable GetItemRecord(EPAssignmentRule rule, IBqlTable item) { PXGraph graph = this.processGraph; Type itemType = item.GetType(); Type ruleType = GraphHelper.GetType(rule.Entity); if (ruleType.IsAssignableFrom(itemType)) { return(item); } if (processMapType.IsAssignableFrom(ruleType) && graph != null) { return(graph.Caches[processMapType].Current as IBqlTable); } if (graph != null) { foreach (CacheEntityItem entry in EMailSourceHelper.TemplateEntity(this, null, item.GetType().FullName, graph.GetType().FullName)) { Type entityType = GraphHelper.GetType(entry.SubKey); if (ruleType.IsAssignableFrom(entityType) && graph.Views.ContainsKey(entry.Key)) { PXView view = graph.Views[entry.Key]; object result = view.SelectSingleBound(new object[] { item }); return((result is PXResult ? ((PXResult)result)[0] : result) as IBqlTable); } } } return(item); }
protected static string GenerateSearchInfo(PXGraph processingGraph, IBqlTable entity) { PXSearchableAttribute attr = processingGraph .Caches[entity.GetType()] .GetAttributes(nameof(INotable.NoteID)) .OfType <PXSearchableAttribute>() .FirstOrDefault(); if (attr == null && entity.GetType() == typeof(CRContact)) { attr = new PXSearchableAttribute(SM.SearchCategory.CR, Messages.ContactOPTypeForIndex, new Type[] { typeof(CRContact.displayName) }, new Type[] { typeof(CRContact.email), typeof(CRContact.phone1), typeof(CRContact.phone2), typeof(CRContact.phone3), typeof(CRContact.webSite) }) { Line1Format = "{0}{1}{2}", Line1Fields = new Type[] { typeof(CRContact.salutation), typeof(CRContact.phone1), typeof(CRContact.email) } }; } return(attr?.BuildContent(processingGraph.Caches[entity.GetType()], entity, null)); }
public PXGraph this[IBqlTable row] { get { Type itemType = row.GetType(); PXCache cache = Graph.Caches[itemType]; Type graphType; object copy = cache.CreateCopy(row); PXPrimaryGraphAttribute.FindPrimaryGraph(cache, ref copy, out graphType); return(this[graphType]); } }
private object GetFieldValue(IBqlTable item, string fieldname, string fieldvalue = null) { PXCache sourceCache = this.Caches[item.GetType()]; object copy = sourceCache.CreateCopy(item); if (fieldvalue != null) { sourceCache.SetValueExt(copy, fieldname, fieldvalue); } else { object newValue; sourceCache.RaiseFieldDefaulting(fieldname, copy, out newValue); sourceCache.SetValue(copy, fieldname, newValue); } return(sourceCache.GetValueExt(copy, fieldname)); }