Skip to main content
Solved

How can I override the 'Location ID' link to open CR Locations instead of AR Locations?


darylbowman
Captain II
Forum|alt.badge.img+13

It would make sense to me that when opening a Location from the ‘Locations’ tab of a Business Account, that CR Locations would open by default. However, it does not, and AR Locations opens instead.

I must admit, I cannot even find where the code is that runs when this is clicked. I believe it executes an Action called ‘ViewLocation’, but I can’t find it and I don’t know how to override it.

Best answer by darylbowman

This isn’t the way I was expecting to solve this need, but here’s what I did:

I added a new Action which opens CR Locations:

public class BusinessAccountMaint_Extension : PXGraphExtension<BusinessAccountMaint>
{
    // Change in what window Locations opens
    public PXAction<BAccount> CstViewLocation;
    [PXUIField(DisplayName = PX.Objects.CR.Messages.ViewLocation, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = false)]
    [PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntry)]
    public IEnumerable cstViewLocation(PXAdapter adapter)
    {
        BAccount bAccount = Base.Caches[typeof(BAccount)].Current as BAccount;

        if (Base.BaseLocations.Current is object && bAccount is object && Base.Caches[typeof(BAccount)].GetStatus(bAccount) != PXEntryStatus.Inserted)
        {
            PX.Objects.CR.Standalone.Location current = Base.BaseLocations.Current;
            LocationMaint graph = PXGraph.CreateInstance<AccountLocationMaint>();
            graph.Location.Current = graph.Location.Search<PX.Objects.CR.Standalone.Location.locationID>(current.LocationID, bAccount.AcctCD);
            PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
        }

        return adapter.Get();
    }
}

 

Then I changed the Location ID ‘Link Command’ to use my custom Action:

 

View original
Did this topic help you find an answer to your question?

5 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • March 9, 2022

Hi, @darylbowman  Yes, LocationID Link action called as “ViewLocation” and the code is available under the LocationDetailsExt.cs file. 

Please find the screenshot below for reference.

 

 


darylbowman
Captain II
Forum|alt.badge.img+13
  • Author
  • 1749 replies
  • March 9, 2022

I saw that, but it didn’t make sense why that would be opening in the AR Locations page.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • March 10, 2022

Oh Okay!!

If Business Account is NOT extended as a Customer OR Vendor, then it will be redirected to the CR Locations

  • If Business Account is extended as a Customer then the system will take you to the Customer Locations i.e. AR Locations.
  •  If Business Account is extended as Vendor then the system will take you to the Vendor Locations i.e. AP Locations.

 


darylbowman
Captain II
Forum|alt.badge.img+13
  • Author
  • 1749 replies
  • March 10, 2022

I guess this makes sense, but CR Location is really what I want to see. How can I override this?


darylbowman
Captain II
Forum|alt.badge.img+13
  • Author
  • 1749 replies
  • Answer
  • March 15, 2022

This isn’t the way I was expecting to solve this need, but here’s what I did:

I added a new Action which opens CR Locations:

public class BusinessAccountMaint_Extension : PXGraphExtension<BusinessAccountMaint>
{
    // Change in what window Locations opens
    public PXAction<BAccount> CstViewLocation;
    [PXUIField(DisplayName = PX.Objects.CR.Messages.ViewLocation, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = false)]
    [PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntry)]
    public IEnumerable cstViewLocation(PXAdapter adapter)
    {
        BAccount bAccount = Base.Caches[typeof(BAccount)].Current as BAccount;

        if (Base.BaseLocations.Current is object && bAccount is object && Base.Caches[typeof(BAccount)].GetStatus(bAccount) != PXEntryStatus.Inserted)
        {
            PX.Objects.CR.Standalone.Location current = Base.BaseLocations.Current;
            LocationMaint graph = PXGraph.CreateInstance<AccountLocationMaint>();
            graph.Location.Current = graph.Location.Search<PX.Objects.CR.Standalone.Location.locationID>(current.LocationID, bAccount.AcctCD);
            PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
        }

        return adapter.Get();
    }
}

 

Then I changed the Location ID ‘Link Command’ to use my custom Action:

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings