Skip to main content

Hi All,

In my custom screen has a PXGrid which is empty in the beginning. After I add new record and press the Verify Vendors button (Some validation is added) then another new empty row added to the grid automatically. Can someone help me out to avoid this scenario?

Following is my custom screens and button click event.

  1. Before the click event
  1.  After the click event
  2. Button click event 

    public PXAction<HMRCVendorRegisterDetail> VerifyVendors;
            ÂPXButton(CommitChanges = true)]
            PXUIField(DisplayName = "Verify Vendors", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = false)]
            protected virtual IEnumerable verifyVendors(PXAdapter adapter)
            {            
                foreach (HMRCVendorRegisterDetail vendorRegisterDetail in VendorRegisterDetail.Select())
                {                
                    if(vendorRegisterDetail.UsrSelect == false)
                    {
                        VendorRegisterDetail.Cache.RaiseExceptionHandling<HMRCVendorRegisterDetail.bAccountID>(vendorRegisterDetail, null, new PXSetPropertyException(Messages.VendorEmptyMessage));
                    }
                    else
                    {
                        //Logic
                    }                   
                    
                }

                return adapter.Get();
            } 

I don’t see anything wrong with your code.

You could try this, but I’m not certain anything different is actually happening:

public PXAction<HMRCVendorRegisterDetail> VerifyVendors;
rPXButton(CommitChanges = true)]
rPXUIField(DisplayName = "Verify Vendors", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = false)]
protected virtual IEnumerable verifyVendors(PXAdapter adapter)
{
var vendorRegisterGraph = adapter.View.Graph as graphtype]
foreach (HMRCVendorRegisterDetail vendorRegisterDetail in vendorRegisterGraph.VendorRegisterDetail.Select())
{
if(vendorRegisterDetail.UsrSelect == false)
{
vendorRegisterGraph.VendorRegisterDetail.Cache.RaiseExceptionHandling<HMRCVendorRegisterDetail.bAccountID>(vendorRegisterDetail, null, new PXSetPropertyException(Messages.VendorEmptyMessage));
}
else
{
//Logic
}
}

return adapter.Get();
}

(notice the tgraphtype] placeholder where you’ll need to insert the name of your graph)


Reply