Skip to main content

Hi Team,

Need to know how to save only selected rows records only. Can someone help me out?

 

Thanks

 

Hi,

 

I would suggest,

Override the RowPersisting event for the lines, in there check to see if the Select box is ticked, if so call the base row persisting method, if not do nothing.

I’m not 100% sure if the do nothing piece will be sufficient to stop the save on the unselected lines.  You might need to do something to remove the lines you don’t want to save from the cache (within the row persisting event) or raise some kind of event.

 

Maybe have a go and share you code if your not getting the outcome you want?

 

JOhn

 

 


Hi @bhagyat25 ,

As @JWS539  suggested use the Row persisting event or override the persist method and implement the logic. Loop all the records and if the select checkbox is marked as false, delete the line items from the grid.

 protected virtual void PrimaryDAC_RowPersisting(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected baseEvent)
        {
            if (e.Row == null) return;

            foreach (DACName obj in ViewName.Select())
            {
                if(obj.Selected==false)
                {
                    View.Delete(obj);
                }
            }
        }
 


Hi @bhagyat25 ,

As @JWS539  suggested use the Row persisting event or override the persist method and implement the logic. Loop all the records and if the select checkbox is marked as false, delete the line items from the grid.

 protected virtual void PrimaryDAC_RowPersisting(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected baseEvent)
        {
            if (e.Row == null) return;

            foreach (DACName obj in ViewName.Select())
            {
                if(obj.Selected==false)
                {
                    View.Delete(obj);
                }
            }
        }
 

Hi @jinin ,

I tried your code but it is not working as I expected. record is moving to the deleted cache from the updated cache list. But still it is updating. 


Hi @bhagyat25 ,

Did u try the same logic with Persist override?

 ÂPXOverride]
 public void Persist(Action del)
 {
     foreach (DACName obj in ViewName.Select())
        {
                if(obj.Selected==false)
                {
                    View.Delete(obj);
                }
            }

            del();
        }


Hi @bhagyat25 ,

Did u try the same logic with Persist override?

  PXOverride]
 public void Persist(Action del)
 {
     foreach (DACName obj in ViewName.Select())
        {
                if(obj.Selected==false)
                {
                    View.Delete(obj);
                }
            }

            del();
        }

Hi @jinin,

How to call this method? Can you please tell me how to call this method in the graph?


Hi @bhagyat25 ,

Did u try the same logic with Persist override?

  PXOverride]
 public void Persist(Action del)
 {
     foreach (DACName obj in ViewName.Select())
        {
                if(obj.Selected==false)
                {
                    View.Delete(obj);
                }
            }

            del();
        }

Hi @jinin,

How to call this method? Can you please tell me how to call this method in the graph?

Hi @bhagyat25 ,

This is the Save action override method. you can use the same code. and write logic inside..


Hi @bhagyat25 ,

Did u try the same logic with Persist override?

  PXOverride]
 public void Persist(Action del)
 {
     foreach (DACName obj in ViewName.Select())
        {
                if(obj.Selected==false)
                {
                    View.Delete(obj);
                }
            }

            del();
        }

Hi @jinin,

How to call this method? Can you please tell me how to call this method in the graph?

Hi @bhagyat25 ,

This is the Save action override method. you can use the same code. and write logic inside..

Hi @jinin, I tried it too. But that method is not calling. In order to confirm that I put a break point in my visual studio project and put a break point and attached the running instance, But that method is not calling.

        ePXOverride]
        public void PersistMethod(Action del, PXCache sender, PXRowSelectedEventArgs e, PXRowSelected baseEvent)
        {
            foreach (HMRCVendorRegisterDetail obj in VendorRegisterDetail.Select())
            {
                if (obj.UsrSelect == false)
                {
                    VendorRegisterDetail.Delete(obj);
                }
            }

            del();
        }


Hi @bhagyat25 ,

Did u try the same logic with Persist override?

  PXOverride]
 public void Persist(Action del)
 {
     foreach (DACName obj in ViewName.Select())
        {
                if(obj.Selected==false)
                {
                    View.Delete(obj);
                }
            }

            del();
        }

Hi @jinin,

How to call this method? Can you please tell me how to call this method in the graph?

Hi @bhagyat25 ,

This is the Save action override method. you can use the same code. and write logic inside..

Hi @jinin, I tried it too. But that method is not calling. In order to confirm that I put a break point in my visual studio project and put a break point and attached the running instance, But that method is not calling.

        ePXOverride]
        public void PersistMethod(Action del, PXCache sender, PXRowSelectedEventArgs e, PXRowSelected baseEvent)
        {
            foreach (HMRCVendorRegisterDetail obj in VendorRegisterDetail.Select())
            {
                if (obj.UsrSelect == false)
                {
                    VendorRegisterDetail.Delete(obj);
                }
            }

            del();
        }

 

public void PersistMethod(Action del, PXCache sender, PXRowSelectedEventArgs e, PXRowSelected baseEvent)

This is wrong

You should use like below(Check my sample above)

public void Persist(Action del) {
 


Reply