Skip to main content
Solved

Sync Smart Panel Values w/ Current Row in Grid

  • September 9, 2023
  • 3 replies
  • 245 views

Forum|alt.badge.img+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.

Best answer by rhooper91

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!

 

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

3 replies

Forum|alt.badge.img+9
  • Semi-Pro III
  • 229 replies
  • September 9, 2023

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


Forum|alt.badge.img+1
  • Author
  • Varsity III
  • 64 replies
  • September 9, 2023

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.


Forum|alt.badge.img+1
  • Author
  • Varsity III
  • 64 replies
  • Answer
  • September 10, 2023

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


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