Solved

Processing Form Button Click Event

  • 12 December 2023
  • 5 replies
  • 113 views

Userlevel 3
Badge

Hi All,

I have created a custom processing screen and now I need to call the processing method using the process buttons. Can some one help me out?

My Processing Class

public class HMRCVerificationProcess : PXGraph<HMRCVerificationProcess>
    {
        public PXCancel<HMRCVendorRegisterDetail> Cancel;
        public SelectFrom<HMRCVendorRegisterDetail>.Where<HMRCVendorRegisterDetail.excludeverification.IsEqual<False>>.ProcessingView AllVerifiedVendors;

        #region Overridden Properties
        public override bool IsDirty => false;
        #endregion

        public HMRCVerificationProcess()
        {
            AllVerifiedVendors.SetProcessCaption("Run");
            AllVerifiedVendors.SetProcessAllCaption("Run All");
        }        

    }

My Graph 

public class HMRCPeriodicVerifyMaint : PXGraph<HMRCPeriodicVerifyMaint>
    {
        public PXSave<HMRCVendorRegisterDetail> Save;
        public PXCancel<HMRCVendorRegisterDetail> Cancel;
        //Or<HMRCVendorRegisterDetail.validTo.IsLess<AccessInfo.businessDate>>
        public SelectFrom<HMRCVendorRegisterDetail>.Where<HMRCVendorRegisterDetail.hMRCVendorVerified.IsEqual<False>>.OrderBy<Asc<HMRCVendorRegisterDetail.validTo>>.View VendorRegisterDetail;

        public SelectFrom<HMRCVendorRegisterDetail>.Where<HMRCVendorRegisterDetail.excludeverification.IsEqual<False>> .View AllVerifiedVendors;

        public bool IsValid = true;

        public SelectFrom<HMRCAPIConfigDetail>.Where<HMRCAPIConfigDetail.active.IsEqual<True>>.View ActiveAPIConfigs;

        public SelectFrom<BAccount>.Where<BAccount.type.IsEqual<PX.Objects.CR.BAccountType.vendorType>>.View VendorAccounts;

        public SelectFrom<PX.Objects.GL.Branch>.View GLBranches;

        //public SelectFrom<BAccount>.Where<BAccount.type.IsEqual<PX.Objects.CR.BAccountType.organizationType>> .View AllComapnyBAccounts;
        public SelectFrom<BAccount>.View AllComapnyBAccounts;
        
        //Other Logics

       

        public PXAction<HMRCVendorRegisterDetail> RunProcess;       
        [PXProcessButton]
        [PXUIField(DisplayName = "Run Process", Enabled = false)]
       
        protected virtual IEnumerable runprocess(PXAdapter adapter)
        {
            bool isMassProcess = adapter.MassProcess;
            
            List<HMRCVendorRegisterDetail> list = new List<HMRCVendorRegisterDetail>();
            foreach (HMRCVendorRegisterDetail order in adapter.Get<HMRCVendorRegisterDetail>())
            {
                list.Add(order);
            }            
            Save.Press();

            PXLongOperation.StartOperation(this, delegate ()
            {
                ConfigExpiredRecords(list, isMassProcess);
            });
            return list;
        }

        public static void ConfigExpiredRecords(List<HMRCVendorRegisterDetail> list,
           bool isMassProcess = false)
        {
            var workOrderEntry = PXGraph.CreateInstance<HMRCPeriodicVerifyMaint>();
           
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] == null)
                    continue;
                HMRCVendorRegisterDetail workOrder = list[i];               
                try
                {
                    workOrderEntry.Clear();
                    workOrderEntry.AllVerifiedVendors.Current = workOrder;                   
                    if (workOrder.ValidTo < DateTime.Now.Date)
                    {
                        workOrder.HMRCVendorVerified = false;
                    }
                   
                    workOrderEntry.AllVerifiedVendors.Update(workOrder);                    
                    workOrderEntry.Actions.PressSave();                    
                    if (isMassProcess)
                    {
                        PXProcessing<HMRCVendorRegisterDetail>.SetInfo(i,
                        string.Format(Messages.ReVerificationDone,
                        workOrder.VerificationNo));
                    }
                }
                catch (Exception e)
                {
                    PXProcessing<HMRCVendorRegisterDetail>.SetError(i, e);
                }
            }
        }
    }

icon

Best answer by bhagyat25 19 December 2023, 10:22

View original

5 replies

Userlevel 7
Badge +11

Hi @bhagyat25 ,

Go through this article. It will help you.

Creating Custom Processing Screens | Acumatica Cloud ERP

Userlevel 3
Badge

I tried. But no luck my event is not firing. 

My Graph

public class HMRCVerificationProcess : PXGraph<HMRCVerificationProcess>
    {
        public PXCancel<HMRCVendorRegisterDetail> Save;
        public PXCancel<HMRCVendorRegisterDetail> Cancel;
        public PXProcessing<HMRCVendorRegisterDetail,Where<HMRCVendorRegisterDetail.excludeverification.IsEqual<False>>> AllVerifiedVendors;

        #region Overridden Properties
        public override bool IsDirty => false;
        #endregion

        public HMRCVerificationProcess()
        {

            AllVerifiedVendors.SetProcessCaption("Run");
            AllVerifiedVendors.SetProcessAllCaption("Run All");

            AllVerifiedVendors.SetProcessDelegate(
               delegate (List<HMRCVendorRegisterDetail> list)
               {
                  VendorCreateUpdate(list);
               });
        }      
        private static void VendorCreateUpdate(List<HMRCVendorRegisterDetail> vendors)
        {
            HMRCVerificationProcess graph = CreateInstance<HMRCVerificationProcess>();
            graph.ProcessVerification(vendors);
        }

        public virtual void ProcessVerification(List<HMRCVendorRegisterDetail> list)
        {
            HMRCPeriodicVerifyMaint g = PXGraph.CreateInstance<HMRCPeriodicVerifyMaint>();
            g.ConfigExpiredRecords(list,true);
        }
    }

 

update method

public void ConfigExpiredRecords(List<HMRCVendorRegisterDetail> list,
           bool isMassProcess = false)
        {
            var workOrderEntry = PXGraph.CreateInstance<HMRCPeriodicVerifyMaint>();

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] == null)
                    continue;
                HMRCVendorRegisterDetail workOrder = list[i];
                try
                {
                    workOrderEntry.Clear();
                    workOrderEntry.AllVerifiedVendors.Current = workOrder;
                    if (workOrder.ValidTo < DateTime.Now.Date)
                    {
                        workOrder.HMRCVendorVerified = false;
                    }

                    workOrderEntry.AllVerifiedVendors.Update(workOrder);
                    workOrderEntry.Actions.PressSave();
                    if (isMassProcess)
                    {
                        PXProcessing<HMRCVendorRegisterDetail>.SetInfo(i,
                        string.Format(Messages.ReVerificationDone,
                        workOrder.VerificationNo));
                    }
                }
                catch (Exception e)
                {
                    PXProcessing<HMRCVendorRegisterDetail>.SetError(i, e);
                }
            }
        }

 

Can someone help me out to resolve this issue?

Thanks

Userlevel 4
Badge

Hi Bhagyat25,

The link Jinin provided is correct and will work if followed exactly.  I have spent a few hours battling this exact scenario in the past.  I’m not 100% the below is correct but this is my experience:

  • Parts of Acumatica are case sensitive.  When I look at your code I notice that the p (highlighted below) in runprocess is lower case.  Try changing to runProcess.

 

  • Sometimes, I have found that you need to publish to get newly coded events to fire.  For example, If your code is in the extension library, and you add a new event, you seem to need to make a point of republishing to get the event to fire.  After that you can make changes to the code within the event and not have to republish.

Maybe give the above a try and let us know the outcome.

 

Thanks,

John.

Userlevel 3
Badge

Hi Bhagyat25,

The link Jinin provided is correct and will work if followed exactly.  I have spent a few hours battling this exact scenario in the past.  I’m not 100% the below is correct but this is my experience:

  • Parts of Acumatica are case sensitive.  When I look at your code I notice that the p (highlighted below) in runprocess is lower case.  Try changing to runProcess.

 

  • Sometimes, I have found that you need to publish to get newly coded events to fire.  For example, If your code is in the extension library, and you add a new event, you seem to need to make a point of republishing to get the event to fire.  After that you can make changes to the code within the event and not have to republish.

Maybe give the above a try and let us know the outcome.

 

Thanks,

John.

Hi @JWS539 ,

Actually, Issue was in my DAC, I didn’t create Selected attribute inside the DAC. After creating that my code works fine.

Thanks

Userlevel 4
Badge

Hi Thanks for the update.  Quite often when I run into these type of issues I change several thins at once and then things start working.  Problem is I’m never 100% sure which of the things I change made the difference.  Hence, the theory that is may be related to case.  Interesting to have confirmation that it wasn’t case on your example.  The problem with applying changes one at a time is it takes ages recompiling, republishing,...

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