Solved

Sync Smart Panel Values w/ Current Row in Grid

  • 9 September 2023
  • 3 replies
  • 149 views

Userlevel 4
Badge +1

Hello,

I am currently trying to open up a smart panel based on values in a grid on the row selected. Unfortunately, the values are not being updated on the filterview (a series of unbound fields I have) when I open it using PXFormula. It works when I open up the first row, but then after that, it doesn’t update with subsequent rows selected. 

To remedy this, I try to update my PXFilter view before running .AskExt.. and it works to update the values, but once I do this it won’t save the updated values. See below for code:

        public PXAction<ModifyDialog> Modify;
[PXButton(CommitChanges = true, DisplayOnMainToolbar = false)]
[PXUIField(DisplayName = "Modify")]
protected void modify()
{
if (UpdateModifyView() != true ||ModifyDialogView.AskExt(true) != WebDialogResult.OK) return;
else { ModifyActivity(); }
}

private bool UpdateModifyView()
{
EPActivityApprove modTPActivity = TimesheetView.Current;
if(modTPActivity is null) return false;

PMTimeActivityExt modTPActivityExt = modTPActivity.GetExtension<PMTimeActivityExt>();
if(modTPActivityExt is null) return false;

ModifyDialogView.Current.TimeIn = modTPActivity.Date;
ModifyDialogView.Update(ModifyDialogView.Current);
return true;
}

private void ModifyActivity()
{
EPActivityApprove modTPActivity = TimesheetView.Current;
if(modTPActivity is null) return;

PMTimeActivityExt modTPActivityExt = modTPActivity.GetExtension<PMTimeActivityExt>();
if(modTPActivityExt is null) return;

//Get Activity
EmployeeActivitiesEntry graphActivity = PXGraph.CreateInstance<EmployeeActivitiesEntry>();
graphActivity.Clear();

graphActivity.Activity.Insert(modTPActivity);
modTPActivity.Date = ModifyDialogView.Current.TimeIn;
graphActivity.Activity.Update(modTPActivity);
graphActivity.Actions.PressSave();

EmployeeFilterView.Current.Status = "CI";
EmployeeFilterView.Update(EmployeeFilterView.Current);
}

So two ways I’m hoping someone can get me input..

  • If I use PXFormula to update the PXFilter values.. how can I ensure it refreshes based on the row selected (see below for my current field declaration).
            #region TimeIn
[PXDateAndTime]
[PXFormula(typeof(Current<PMTimeActivityExt.usrBlyTimeIn>))]
[PXUIField(DisplayName = "Time In")]
public virtual DateTime? TimeIn { get; set; }
public abstract class timeIn : PX.Data.BQL.BqlDateTime.Field<timeIn> { }
#endregion
  • If not, why is my code not updating the graph when I don’t call the modifycurrentfilter vs when I do.
icon

Best answer by rhooper91 10 September 2023, 05:36

View original

3 replies

Userlevel 7
Badge +10

Hi @rhooper91 ,

Use the PXDefault attribute to set the default value of your filter fields instead of relying solely on PXFormula.

#region TimeIn
[PXDateAndTime]
[PXDefault(typeof(PMTimeActivityExt.usrBlyTimeIn), PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Time In")]
public virtual DateTime? TimeIn { get; set; }
public abstract class timeIn : PX.Data.BQL.BqlDateTime.Field<timeIn> { }
#endregion

PXDefault attribute will set the default value of the TimeIn field to the value of PMTimeActivityExt.usrBlyTimeIn when a new filter record is created. This should ensure that the filter view refreshes based on the selected row when you open the smart panel.

 

Ensure that the PXUIField attributes on your filter fields have the CommitChanges = true property set. This will ensure that changes to the filter fields are committed to the database when you select a row.

 

Regards,

Sweta

Userlevel 4
Badge +1

Hey @sweta68 - 

Thanks for the response, unfortunately I am still getting the same issue.. when I select the first row, and select the grid action I get 2:49 populated in my pop up panel. But then when I select the second and then grid action, I get 2:49 again. Then if I reload the page and select the second row first, I get 8:49, and then when I close the dialog and then select the second and open the popup, I get 8:49.. it gets stuck on the row value I select and won’t re-default.


See below for example where I select second row first..

Then close and select first row..

I would expect to see 2:49 in the second scenario.

Userlevel 4
Badge +1

Hey All-

As an update.. I had to take an entirely different approach.. I ended up splitting it into two different actions:

  1. Visible action → I am no longer calling .askext() in the code. Instead, referencing the popup id in the action button ui. Then the action itself is only updating the popup panel values based on the grid value selected.
  2. Non-visible action → I have tied a new method to the AutoCallback command on the ‘OK’ button which allows me to split out the popup panel update logic and then actually saving to the database. 

This isn’t the first time that I have found the .viewext() to not fire appropriately. There are some other articles where this exact issue has happened to others as well, the code just doesn’t fire.

Thanks!

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved