Skip to main content
Answer

how to access and enable/disable standard buttons on smart panels

  • March 7, 2022
  • 3 replies
  • 610 views

aaghaei
Captain II
Forum|alt.badge.img+10

By using PXUIFieldAttribute.SetEnabled we can access to the fields and modify their properties. I was wondering how.we can access to the standard buttons like as ok, cancel … on the smart panels and modify their properties?

Best answer by aaghaei

Thanks @Naveen B & @yhartman,

yes, with a little bit of help I figured this out. Here is what I did.

 

        protected virtual void APInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
var row = e.Row as APInvoice;
if (row != null)
{
bool Enabled = (row.Status == APStatuses.PendingApproval || row.Status == APStatuses.Rejected || row.Status == APStatuses.OnHold) ? true : false;
route.SetEnabled(Enabled);
}

if (RoutingPanelDialog.Current != null)
{
bool Enabled = false;
Enabled = (RoutingPanelDialog.Current.Status == EPStatuses.Routed) ? false : true;
PXUIFieldAttribute.SetEnabled<EPRoutingPanelDialog.step>(cache, null, Enabled);

Enabled = false;
if (RoutingPanelDialog.Current.Step != null)
{
if (RoutingPanelDialog.Current.Owner != null || RoutingPanelDialog.Current.Workgroup != null)
{
Enabled = true;
}
}

ChangeOk.SetEnabled(Enabled);
}
}

 

3 replies

Forum|alt.badge.img+3
  • Jr Varsity I
  • March 9, 2022

Create a button for your smart panel and assign the dialog result to the desired option.

 

 

Than in your code you can access the action like any other. Make sure that the panel button is set to the correct CommandName and CommandSourceID.


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

 Hi @aaghaei  I just worked on a similar kind of requirement.

In the smart panel, I have added 3 buttons Add, Add&Close, and Cancel. Provided the command names at the Smart Panel (.aspx page)

In the Row_Selected event, written a condition like, if the provided value is less than 5 then I’m disabling the buttons (Add and Add&Close) and if the value is more than 5 then I’m enabling the smart panel buttons

 

Please find the screenshots for reference.

 

 

 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • Answer
  • March 9, 2022

Thanks @Naveen B & @yhartman,

yes, with a little bit of help I figured this out. Here is what I did.

 

        protected virtual void APInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
var row = e.Row as APInvoice;
if (row != null)
{
bool Enabled = (row.Status == APStatuses.PendingApproval || row.Status == APStatuses.Rejected || row.Status == APStatuses.OnHold) ? true : false;
route.SetEnabled(Enabled);
}

if (RoutingPanelDialog.Current != null)
{
bool Enabled = false;
Enabled = (RoutingPanelDialog.Current.Status == EPStatuses.Routed) ? false : true;
PXUIFieldAttribute.SetEnabled<EPRoutingPanelDialog.step>(cache, null, Enabled);

Enabled = false;
if (RoutingPanelDialog.Current.Step != null)
{
if (RoutingPanelDialog.Current.Owner != null || RoutingPanelDialog.Current.Workgroup != null)
{
Enabled = true;
}
}

ChangeOk.SetEnabled(Enabled);
}
}