Selector shows correct information but when selected, it returns the wrong value

  • 29 November 2023
  • 1 reply

Userlevel 6
Badge +3

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
[PXUIField(DisplayName = "Lookup Project Task")]
InnerJoin<PMProject, On<PMProject.contractID, Equal<PMTask.projectID>>>,
Where<PMProject.isActive, Equal<True>>>),
SubstituteKey = typeof(PMTask.taskCD),
DescriptionField = typeof(PMTask.description))]
public int? UsrProjectTaskID { get; set; }
public abstract class usrProjectTaskID : PX.Data.BQL.BqlInt.Field<usrProjectTaskID> { }

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.


Best answer by Joe Schmucker 1 December 2023, 17:30

View original

1 reply

Userlevel 6
Badge +3

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
.And<PMProject.baseType.IsEqual<PX.Objects.CT.CTPRType.project>>>), Persistent = false)]
public class PMProjectProjectionAP : IBqlTable
#region ContractID
[PXDBInt(IsKey = true, BqlField = typeof(PMProject.contractID))]
public virtual Int32? ContractID { get; set; }
public abstract class contractID : PX.Data.BQL.BqlInt.Field<contractID> { }

#region ContractCD
[PXDBString(30, IsUnicode = true, BqlField = typeof(PMProject.contractCD))]
[PXUIField(DisplayName = "Project ID")]
public virtual String ContractCD { get; set; }
public abstract class contractCD : PX.Data.BQL.BqlString.Field<contractCD> { }

#region TaskID
[PXDBInt(BqlField = typeof(PMTask.taskID))]
[PXUIField(DisplayName = "TaskID")]
public virtual Int32? TaskID { get; set; }
public abstract class taskID : PX.Data.BQL.BqlInt.Field<taskID> { }

#region ProjectDescription
[PXDBString(255, IsUnicode = true, BqlField = typeof(PMProject.description))]
[PXUIField(DisplayName = "Project Description")]
public virtual String ProjectDescription { get; set; }
public abstract class projectDescription : PX.Data.BQL.BqlString.Field<projectDescription> { }

#region TaskDescription
[PXDBString(250, IsUnicode = true, BqlField = typeof(PMTask.description))]
[PXUIField(DisplayName = "Task Description")]
public virtual String TaskDescription { get; set; }
public abstract class taskDescription : PX.Data.BQL.BqlString.Field<taskDescription> { }

#region UsrTaskCD
[PXDBString(30, IsUnicode = true, BqlField = typeof(PMTask.taskCD))]
[PXUIField(DisplayName = "Task ID")]
public virtual String UsrTaskCD { get; set; }
public abstract class usrTaskCD : PX.Data.BQL.BqlString.Field<usrTaskCD> { }

#region Status
[PXDBString(1, BqlField = typeof(PMProject.status))]
[PXUIField(DisplayName = "Status", Visible = false)]
public virtual String Status { get; set; }
public abstract class status : PX.Data.BQL.BqlString.Field<status> { }

#region BaseType
[PXDBString(1, BqlField = typeof(PMProject.baseType))]
[PXUIField(DisplayName = "BaseType", Visible = false)]
public virtual String BaseType { get; set; }
public abstract class baseType : PX.Data.BQL.BqlString.Field<baseType> { }


This is the code to override the selector:

		#region Event Handlers
[ProjectDefault(BatchModule.TA, ForceProjectExplicitly = true)]
SubstituteKey = typeof(PMProjectProjectionAP.contractCD),
DescriptionField = typeof(PMProjectProjectionAP.contractCD))]
protected virtual void EPTimecardDetail_ProjectID_CacheAttached(PXCache cache)


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.


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved