Skip to main content
Answer

Adding fields to Location selector

  • May 6, 2024
  • 5 replies
  • 195 views

DrewNisley
Pro I
Forum|alt.badge.img+3

I have been trying to learn and get this to work, but I haven’t had any luck. I am trying to add the AddressLine1 field to the location selector on the opportunities screen. I have done some digging and have come across this, but all it spit out was the LocationID and Description with bad looking column headings, the same as what happened here. I tried his fix of moving it to a visual studio project and that didn’t work for me either, I had the same outcome. I also tried using this method, changing from contact to address. It seems to work (I can see the AddressLine1), but I can see every single one in the system, not just the ones related to the BAccount I have selected on the opportunity. If someone could give me a hand, that would be great, I’m still new to coding. Here is the code I am using currently.

[PXSelector(typeof(SearchFor<Location.locationCD>.In<SelectFrom<Location>.InnerJoin
<Address>.On<Location.defAddressID.IsEqual<Address.addressID>>>),
typeof(Location.locationCD),
typeof(Location.descr),
typeof(Address.addressLine1),
SubstituteKey = typeof(Location.locationCD), DescriptionField =
typeof(Location.descr))]

 

Best answer by DrewNisley

I ended up finding this on the community and modified it to fit this situation and it worked perfectly. Just had to make sure to add the SubstituteKey for it to use the LocationCD instead of the LocationID or else it will throw errors. 

[PXMergeAttributes(Method = MergeMethod.Append)]
[BAcctLocOpp(typeof(Search2<Location.locationID, InnerJoin<Address, On<Location.defAddressID, Equal<Address.addressID>>>,
Where<Location.bAccountID, Equal<Current<CROpportunity.bAccountID>>>>), SubstituteKey = typeof(Location.locationCD), DescriptionField = typeof(Location.descr))]
using System;
using PX.Data;
using PX.Objects.CR;

namespace SelectorFields
{
public class BAcctLocOppAttribute : PXSelectorAttribute
{
#region Event Handlers
public BAcctLocOppAttribute(Type SearchType)
:base(SearchType,
typeof(Location.descr),
typeof(Location.locationCD),
typeof(Address.addressLine1),
typeof(Address.addressLine2),
typeof(Address.city),
typeof(Address.state),
typeof(Address.postalCode))
{
}
protected override bool IsReadDeletedSupported => false;
#endregion
}
}

 

5 replies

Vignesh Ponnusamy
Acumatica Moderator
Forum|alt.badge.img+5

Hi @DrewNisley,

You can try like below to see if that helps,

        #region CustomerLocationID
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRemoveBaseAttribute(typeof(LocationIDAttribute))] //Removing the LocationIDAttribute and redefining in the below line
[LocationID(typeof(Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>,
And<Location.isActive, Equal<True>,
And<MatchWithBranch<Location.cBranchID>>>>),
typeof(InnerJoin<Address, On<Location.bAccountID, Equal<Address.bAccountID>, And<Location.defAddressID, Equal<Address.addressID>>>>) //Joining Address table to fetch the columns in the address
,DescriptionField = typeof(Location.descr), Visibility = PXUIVisibility.SelectorVisible)]
[PXCustomizeSelectorColumns(typeof(PX.Objects.CR.Address.addressLine1), //Adding the column to the Selector
typeof(PX.Objects.CR.Address.addressLine2),
typeof(PX.Objects.CR.Address.city),
typeof(PX.Objects.CR.Address.state),
typeof(PX.Objects.CR.Address.postalCode))]
public int? CustomerLocationID { get; set; }
#endregion

I tried it a while ago and assume it should still work(might have check the DAC names to see if it has changed). Please feel free to post if you have any questions. Good Luck.!


DrewNisley
Pro I
Forum|alt.badge.img+3
  • Author
  • Pro I
  • May 7, 2024

Hi @Vignesh Ponnusamy,

Thank you for the response.

I had to change LocationIDAttribute to LocationActiveAttribute and LocationID to LocationActive because it said it was obsolete. Otherwise, everything validated well. I’m still not seeing any changes to the selector columns, although it is not broken like when I was originally doing it and it is showing the correct corresponding locations to the BAccount.

This is the current code. It makes sense in my brain, I just don’t know what’s not working. Would it be a version issue? I’m on 22R2 right now

        [PXMergeAttributes(Method = MergeMethod.Append)]
[PXRemoveBaseAttribute(typeof(LocationActiveAttribute))]
[LocationActive(typeof(Where<Location.bAccountID, Equal<Current<CROpportunity.bAccountID>>,
And<Location.isActive, Equal<True>,
And<MatchWithBranch<Location.cBranchID>>>>),
typeof(InnerJoin<Address, On<Location.bAccountID, Equal<Address.bAccountID>, And<Location.defAddressID, Equal<Address.addressID>>>>),
DescriptionField = typeof(Location.descr), Visibility = PXUIVisibility.SelectorVisible)]
[PXCustomizeSelectorColumns(typeof(PX.Objects.CR.Address.addressLine1),
typeof(PX.Objects.CR.Address.addressLine2),
typeof(PX.Objects.CR.Address.city),
typeof(PX.Objects.CR.Address.state),
typeof(PX.Objects.CR.Address.postalCode))]

 


DrewNisley
Pro I
Forum|alt.badge.img+3
  • Author
  • Pro I
  • Answer
  • May 7, 2024

I ended up finding this on the community and modified it to fit this situation and it worked perfectly. Just had to make sure to add the SubstituteKey for it to use the LocationCD instead of the LocationID or else it will throw errors. 

[PXMergeAttributes(Method = MergeMethod.Append)]
[BAcctLocOpp(typeof(Search2<Location.locationID, InnerJoin<Address, On<Location.defAddressID, Equal<Address.addressID>>>,
Where<Location.bAccountID, Equal<Current<CROpportunity.bAccountID>>>>), SubstituteKey = typeof(Location.locationCD), DescriptionField = typeof(Location.descr))]
using System;
using PX.Data;
using PX.Objects.CR;

namespace SelectorFields
{
public class BAcctLocOppAttribute : PXSelectorAttribute
{
#region Event Handlers
public BAcctLocOppAttribute(Type SearchType)
:base(SearchType,
typeof(Location.descr),
typeof(Location.locationCD),
typeof(Address.addressLine1),
typeof(Address.addressLine2),
typeof(Address.city),
typeof(Address.state),
typeof(Address.postalCode))
{
}
protected override bool IsReadDeletedSupported => false;
#endregion
}
}

 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • May 7, 2024

Thank you for sharing your solution with the community @DrewNisley!


Vignesh Ponnusamy
Acumatica Moderator
Forum|alt.badge.img+5

@DrewNisley, Good to know, thanks for sharing.!