Question

Can't get Setup form to be triggered when there is no current record

  • 16 June 2021
  • 5 replies
  • 240 views

Userlevel 6
Badge +3

I have a setup table (ICSetup) which obviously should have only one record.  When the table is empty and a graph tries to get the setup record, it is supposed to throw an exception to the screen and give the user the option to redirect to the setup form.  This is not working for me.  I debugged the code and the constructor call is creating the exception, but nothing is coming back to the screen.  It just hangs.

Here is the DAC:

 

You can see that I have setup the PXPrimaryGraph to ICSetupMaint.  That screen opens with no issue.

In the InterTenantMaint graph, I have a PXSelect as follows:

public PXSetup<ICSetup> Setup;

The constructor for the graph is:

    public InterTenantMaint()
        {
            try
            {
                ICSetup setup = Setup.Current;
            }
            catch (Exception e)
            {
                string joe = e.Message;
            }
        }

 

When you open the InterTenantMaint screen, it just hangs.

In order to debug, I added a try-catch to see what the error is.  When the try executes the e.Message value is as I would expect. 

If you open the ICSetupMaint screen, it looks fine.  I made sure not to save a record on that screen so that it would be empty for this test.

I implemented this code exactly like the Acumatica Training code.

Why is the exception not coming back to the screen with the normal dialog to allow the user to go to the setup form?  The screen just hangs with nothing displayed and the “circle” spins forever.  Note that I only added the try-catch to get the error.  Normally, the code just has the line in the try statement.

Thanks,

Joe


5 replies

Userlevel 6
Badge +3

Also, this is in ERP 2021 R1.

Userlevel 7
Badge +17

Hi Joe,

I have similar setup screen in one of projects and Sales Order screen throw an error message if details are NOT provided on the setup screen. 

public PXSetup<DACName> Setupview; // this is enough.

I never used that constructor code, and I don’t think it required. Please remove and check once.

 

Sales Order screen

  

 

 

 

Hope this helps!!

Userlevel 6
Badge +3

I removed the constructor.  It no longer hangs.  However, it ignores the fact that there is no setup record and just displays the screen as if everything was good to go.

If I sound frustrated, it is because I am.  I can spend 1 hour on complicated coding that works but the basic things that should work in Acumatica cause me several hours to fix or work around.

I did a workaround and check if the table is null on the row selected event for the primary view.

 

        protected void _(Events.RowSelected<ICInterTenantMaint> e)
        {
            bool useIntertenant = false;
            
            ICInterTenantMaint row = e.Row;

            if (row == null) return;

            ICSetup setup = Setup.Select();

            if (setup == null)
            {
                PXUIFieldAttribute.SetEnabled<ICInterTenantMaint.organizationID>(e.Cache, row, false);

                e.Cache.RaiseExceptionHandling<ICInterTenantMaint.organizationID>(e.Row, e.Row.OrganizationID,
                     new PXSetPropertyException(Messages.ICInterTenantIsNotEnabled, PXErrorLevel.Warning));
            }
            else
            {
                useIntertenant = true;
            }
 

This SHOULD be a simple thing.  The PXSelect is null and as I understand should kick an exception to the screen.  It simply does not.

Userlevel 7
Badge +17

Joe, I understand that but I’m NOT sure, why that is not throwing the error message.


Can you do one verification by commenting the RowSelected code and also comment the PXDefault(false) from DAC fields and verify once.

Userlevel 6
Badge +3

I commented out the Default in the DAC for both fields:

 

    [Serializable]
    [PXCacheName("IC Setup Maintenance")]
    [PXPrimaryGraph(typeof(ICSetupMaint))]
    public class ICSetup : IBqlTable
    {

        #region UseInterTenant
        [PXDBBool]
        //[PXDefault(false)]
        [PXUIField(DisplayName = "Use Inter-Tenant")]
        public virtual bool? UseInterTenant { get; set; }
        public abstract class useInterTenant : PX.Data.BQL.BqlBool.Field<useInterTenant> { }
        #endregion

        #region UseProjectIDTracker
        [PXDBBool]
        //[PXDefault(false)]
        [PXUIField(DisplayName = "Use Project ID Tracker")]
        public virtual bool? UseProjectIDTracker { get; set; }
        public abstract class useProjectIDTracker : PX.Data.BQL.BqlBool.Field<useProjectIDTracker> { }
        #endregion

 

I commented out all code on the graph except for the views this:

    public class InterTenantMaint : PXGraph<InterTenantMaint, ICInterTenantMaint>
    {

        public SelectFrom<ICInterTenantMaint>.View MasterView;

        public SelectFrom<ICAccountMapping>
            .Where<ICAccountMapping.organizationID.IsEqual<ICInterTenantMaint.organizationID.FromCurrent>>.View AccountMapping;

        public SelectFrom<ICSubaccountMapping>
            .Where<ICSubaccountMapping.organizationID.IsEqual<ICInterTenantMaint.organizationID.FromCurrent>>.View SubaccountMapping;

        public SelectFrom<ICBranchMapping>.InnerJoin<Branch>.On<Branch.branchID.IsEqual<ICBranchMapping.sourceBranchID>>
                .InnerJoin<BAccount>.On<BAccount.bAccountID.IsEqual<Branch.bAccountID>>
            .Where<ICBranchMapping.organizationID.IsEqual<ICInterTenantMaint.organizationID.FromCurrent>>.View BranchMapping;

        public PXSetup<ICSetup> Setup;


        //used for bulk adding of GL accounts to AccountMapping table
        public SelectFrom<Account>.View.ReadOnly AccountListing;

        //used for bulk adding of GL accounts to AccountMapping table
        public SelectFrom<Sub>.View.ReadOnly SubaccountListing;


        //used for bulk adding of branches to BranchMapping table
        public SelectFrom<Branch>
            .Where<Branch.organizationID.IsEqual<ICInterTenantMaint.organizationID.FromCurrent>>.View.ReadOnly Branches;

}

I still do not get an error to direct me to the setup form and the form displays as usual.

This is the only thing on the ICSetupMaint graph:

    public class ICSetupMaint : PXGraph<ICSetupMaint>
    {

        public PXSave<ICSetup> Save;
        public PXCancel<ICSetup> Cancel;

        public SelectFrom<ICSetup>.View Setup;

    }

In case this is useful info, the ICSetupMaint form works fine.  If I save a record to the setup table, there are no problems.  I then truncate that table to try to cause the setup screen error to occur.  

I compared my setup form to the rssv setup form in the training and the only difference is the fields I have on my setup form.

 

Thanks for the efforts here Naveen.  

 

 

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