Skip to main content
Answer

How to dynamically change NavigateURL property of a button?

  • July 5, 2024
  • 3 replies
  • 79 views

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

I’m trying to dynamically update the NavigateURL property of a button using an event handler.  Is this possible?  Has anyone else ever managed to do this?

Best answer by Vignesh Ponnusamy

In the case, you can check the values of those fields with the action method itself → change the NavigateURL → Redirect. So I don’t think you we need to use event handlers in this case.

Please correct me if I’m not getting the scenario right. Thanks,

3 replies

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

Hi @DavidEichner,

Can you please share more details of the scenario that requires this?

As you are invoking the action, I think you can set the redirect URL directly in the action’s method based on the condition. Below is an example of the suggestion,

        public PXAction<SOOrder> action;
[PXUIField(DisplayName = "Open Window")]
[PXButton]
protected IEnumerable Action(PXAdapter adapter)
{
if (Base.Transactions.Select().Count > 0)
{
string url = "https://www.acumatica.com";
throw new PXException($"Redirect0:{url}$target=_top");
}
else
{
string url = "https://www.google.com";
throw new PXException($"Redirect0:{url}$target=_top");
}
return adapter.Get();
}

Good Luck,


DavidEichner
Captain II
Forum|alt.badge.img+13
  • Author
  • Captain II
  • July 5, 2024

We have created a button that should change the NavigateURL of that button to a different value based on the value in a specific field of the record when the record is selected OR when that specific field is changed/updated.  


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

In the case, you can check the values of those fields with the action method itself → change the NavigateURL → Redirect. So I don’t think you we need to use event handlers in this case.

Please correct me if I’m not getting the scenario right. Thanks,