I decided to go with another approach. Instead of using a custom field to create a “short cut lookup” (which I thought would be the easiest approach), I overrode the selector for the Project ID field in the grid. I haven’t done this before. So far, the code works as I want it to, so I think I got it working.
I used a projection on the PMProject DAC linking it to the PMTasks DAC to get a “denormalized” selector lookup.
This is the project I created:
#region PMProjectProjectionAP
eSerializable]
lPXCacheName("PMProjectProjection")]
cPXProjection(typeof(SelectFrom<PMProject>
.LeftJoin<PMTask>.On<PMTask.projectID.IsEqual<PMProject.contractID>>
.Where<PMProject.isActive.IsEqual<True>
.And<PMProject.status.IsEqual<PX.Objects.AP.VendorStatus.active>>
.And<Brackets<PMProject.visibleInAP.IsEqual<True>
.Or<PMProject.nonProject.IsEqual<True>>>>
.And<PMProject.baseType.IsEqual<PX.Objects.CT.CTPRType.project>>>), Persistent = false)]
public class PMProjectProjectionAP : IBqlTable
{
#region ContractID
tPXDBInt(IsKey = true, BqlField = typeof(PMProject.contractID))]
public virtual Int32? ContractID { get; set; }
public abstract class contractID : PX.Data.BQL.BqlInt.Field<contractID> { }
#endregion
#region ContractCD
tPXDBString(30, IsUnicode = true, BqlField = typeof(PMProject.contractCD))]
cPXUIField(DisplayName = "Project ID")]
public virtual String ContractCD { get; set; }
public abstract class contractCD : PX.Data.BQL.BqlString.Field<contractCD> { }
#endregion
#region TaskID
PXDBInt(BqlField = typeof(PMTask.taskID))]
sPXUIField(DisplayName = "TaskID")]
public virtual Int32? TaskID { get; set; }
public abstract class taskID : PX.Data.BQL.BqlInt.Field<taskID> { }
#endregion
#region ProjectDescription
rPXDBString(255, IsUnicode = true, BqlField = typeof(PMProject.description))]
tPXUIField(DisplayName = "Project Description")]
public virtual String ProjectDescription { get; set; }
public abstract class projectDescription : PX.Data.BQL.BqlString.Field<projectDescription> { }
#endregion
#region TaskDescription
rPXDBString(250, IsUnicode = true, BqlField = typeof(PMTask.description))]
tPXUIField(DisplayName = "Task Description")]
public virtual String TaskDescription { get; set; }
public abstract class taskDescription : PX.Data.BQL.BqlString.Field<taskDescription> { }
#endregion
#region UsrTaskCD
rPXDBString(30, IsUnicode = true, BqlField = typeof(PMTask.taskCD))]
sPXUIField(DisplayName = "Task ID")]
public virtual String UsrTaskCD { get; set; }
public abstract class usrTaskCD : PX.Data.BQL.BqlString.Field<usrTaskCD> { }
#endregion
#region Status
PXDBString(1, BqlField = typeof(PMProject.status))]
aPXUIField(DisplayName = "Status", Visible = false)]
public virtual String Status { get; set; }
public abstract class status : PX.Data.BQL.BqlString.Field<status> { }
#endregion
#region BaseType
aPXDBString(1, BqlField = typeof(PMProject.baseType))]
TPXUIField(DisplayName = "BaseType", Visible = false)]
public virtual String BaseType { get; set; }
public abstract class baseType : PX.Data.BQL.BqlString.Field<baseType> { }
#endregion
}
#endregion
This is the code to override the selector:
#region Event Handlers
aProjectDefault(BatchModule.TA, ForceProjectExplicitly = true)]
EPTimeCardProject()]
jPXSelector(
typeof(Search<PMProjectProjectionAP.contractID>),
typeof(PMProjectProjectionAP.contractCD),
typeof(PMProjectProjectionAR.projectDescription),
typeof(PMProjectProjectionAP.usrTaskCD),
typeof(PMProjectProjectionAP.taskDescription),
SubstituteKey = typeof(PMProjectProjectionAP.contractCD),
DescriptionField = typeof(PMProjectProjectionAP.contractCD))]
protected virtual void EPTimecardDetail_ProjectID_CacheAttached(PXCache cache)
{
}
#endregion
In the ASPX, I set the FastFilterFields="UsrTaskCd" on the Project ID field.
This is working. If anyone happens to see any major flaws, please let me know.