Skip to main content
Answer

Add address fields to the Location selector not returning address fields

  • December 27, 2023
  • 3 replies
  • 91 views

Joe Schmucker
Captain II
Forum|alt.badge.img+3

I am trying to add address fields to the Location selector on the Opportunities screen.

I copied the code from Sergey’s blog at https://asiablog.acumatica.com/2015/10/customizing-selector-attributes.html

From the blog, the code is like this:

		#region CustomerLocationID
public abstract class customerLocationID : PX.Data.IBqlField
{
}
[PXMergeAttributesAttribute(Method = MergeMethod.Merge)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.CR.Location.locationCD),
typeof(PX.Objects.CR.Location.descr),
typeof(PX.Objects.CR.Address.addressLine1))]
[LocationID(typeof(Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>,
And<Location.isActive, Equal<True>, And<MatchWithBranch<Location.cBranchID>>>>),
typeof(InnerJoin<Address, On<Location.defAddressID, Equal<Address.addressID>>>),
DescriptionField = typeof(Location.descr), Visibility = PXUIVisibility.SelectorVisible)]
public int? CustomerLocationID { get; set; }

#endregion

My code is almost exactly the same except I am using LocationID instead of CustomerLocationID

    public abstract class locationID : PX.Data.IBqlField
{
}
[PXMergeAttributesAttribute(Method = MergeMethod.Merge)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.CR.Location.locationCD),
typeof(PX.Objects.CR.Location.descr),
typeof(PX.Objects.CR.Address.addressLine1))]
[LocationActive(typeof(Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>,
And<Location.isActive, Equal<True>, And<MatchWithBranch<Location.cBranchID>>>>),
typeof(InnerJoin<Address, On<Location.defAddressID, Equal<Address.addressID>>>),
DescriptionField = typeof(Location.descr), Visibility = PXUIVisibility.SelectorVisible)]
public int? LocationID { get; set; }

#endregion

I also changed [LocationID to [LocationActive as the LocationID attribute is obsolete.

This is what I get on the lookup:

The descriptions are yuk and it doesn’t show the address fields.

Any advice on what I am doing wrong?

 

 

Best answer by Joe Schmucker

I found a way to get this to work.  Instead of using the project editor, I moved it to an extension library in VS.  I don’t know why it makes any difference, but this works.  Originally I tried using the code from the original DAC.  It included a couple extra items that are not in the extension generated by the Project Editor when I converted to extension.  (And<Location.isActive, Equal<True>, And<MatchWithBranch<Location.cBranchID>>)

I’d add those lines in and try it again to see if that was the error, but I’ve spent way too much time on this.  At least this code works.

 

	public class CROpportunityExtCummings : PXGraphExtension<PX.Objects.CR.OpportunityMaint>
{
[PXMergeAttributesAttribute(Method = MergeMethod.Merge)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.CR.Location.locationCD),
typeof(PX.Objects.CR.Location.descr),
typeof(PX.Objects.CR.Address.addressLine1))]
[LocationActive(typeof(Where<Location.bAccountID, Equal<Current<CROpportunity.bAccountID>>>),
typeof(InnerJoin<Address, On<Location.defAddressID, Equal<Address.addressID>>>),
DisplayName = "Account Location",
DescriptionField = typeof(Location.descr),
BqlField = typeof(Standalone.CROpportunityRevision.locationID))]
protected virtual void CROpportunity_LocationID_CacheAttached(PXCache cache)
{

}
}

 

3 replies

Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • December 27, 2023

I thought I had it!  I found a copy/paste error.

[LocationActive(typeof(Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>,

Should be

[LocationActive(typeof(Where<Location.bAccountID, Equal<Current<CROpportunity.bAccountID>>,

No luck.  The results are the same.


Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • Answer
  • December 28, 2023

I found a way to get this to work.  Instead of using the project editor, I moved it to an extension library in VS.  I don’t know why it makes any difference, but this works.  Originally I tried using the code from the original DAC.  It included a couple extra items that are not in the extension generated by the Project Editor when I converted to extension.  (And<Location.isActive, Equal<True>, And<MatchWithBranch<Location.cBranchID>>)

I’d add those lines in and try it again to see if that was the error, but I’ve spent way too much time on this.  At least this code works.

 

	public class CROpportunityExtCummings : PXGraphExtension<PX.Objects.CR.OpportunityMaint>
{
[PXMergeAttributesAttribute(Method = MergeMethod.Merge)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.CR.Location.locationCD),
typeof(PX.Objects.CR.Location.descr),
typeof(PX.Objects.CR.Address.addressLine1))]
[LocationActive(typeof(Where<Location.bAccountID, Equal<Current<CROpportunity.bAccountID>>>),
typeof(InnerJoin<Address, On<Location.defAddressID, Equal<Address.addressID>>>),
DisplayName = "Account Location",
DescriptionField = typeof(Location.descr),
BqlField = typeof(Standalone.CROpportunityRevision.locationID))]
protected virtual void CROpportunity_LocationID_CacheAttached(PXCache cache)
{

}
}

 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • December 28, 2023

Thank you for sharing your solution with the community @Joe Schmucker!