Skip to main content

I added a custom field to the Bills and Adjustments screen Details grid.

The users want to be able to lookup the project id by filtering on the Task ID.  They KNOW the task ID, but they don’t know the Project and the Project lookup only lists the projects.

My custom lookup pulls from the PMTasks table and is joined to the PMProjects DAC. My lookup allows you to filter on the Task ID.

When you select the first line shown in the print screen, it should be returning Task ID 1652.

In the code, it is returning 1584 no matter which item is selected in the grid.

This is the DAC Extension showing my Selector.  Is there something wrong with it?  the Grid shows the TaskID so I can see it is unique.  I don’t plan to show the integer, but I am showing it for debugging purposes, .

	public sealed class APTranExt : PXCacheExtension<PX.Objects.AP.APTran>
{
#region UsrProjectTaskID
DPXUIField(DisplayName = "Lookup Project Task")]
]PXSelector(
typeof(Search2<PMTask.taskID,
InnerJoin<PMProject, On<PMProject.contractID, Equal<PMTask.projectID>>>,
Where<PMProject.isActive, Equal<True>>>),
typeof(PMProject.contractCD),
typeof(PMTask.taskID),
typeof(PMTask.taskCD),
typeof(PMTask.description),
SubstituteKey = typeof(PMTask.taskCD),
DescriptionField = typeof(PMTask.description))]
public int? UsrProjectTaskID { get; set; }
public abstract class usrProjectTaskID : PX.Data.BQL.BqlInt.Field<usrProjectTaskID> { }
#endregion
}

In debug, the value in the custom field is 1584, even though I selected the first record:

If I remove the join to the PMProject DAC, the same thing still happens.  It returns 1584 no matter which record I choose.

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.


Reply