Skip to main content
Solved

How to dynamically change NavigateURL property of a button?

  • 5 July 2024
  • 3 replies
  • 29 views

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?

3 replies

Userlevel 7
Badge +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,

Userlevel 7
Badge +12

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.  

Userlevel 7
Badge +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,

Reply