Skip to main content
Solved

Adding a smart panel to SO301000 to show what other orders a customer has placed, only shows one order in grid.


Forum|alt.badge.img

Hello, I am currently trying to add a smart panel that just shows other orders a customer has placed. I used this vlog as a guide: https://www.acumatica.com/blog/vlog-changing-an-acumatica-po-number-with-a-smart-panel-and-custom-action/

It got me most of the way there. Currently I have the dialog box popping up and I am able to close it. In the code I can see that I am pulling all orders that a customer has made. However, the grid in the dialog box only shows one item in it and I am not exactly sure why that would be. I thought it might be related to this other forum post: 

 

But since I am seeing something in my grid, I think I am making a different mistake.

 

namespace PX.Objects.SO {
    // Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
    public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
    {

        public PXFilter<MSCustomerOrderDac> MSCustomerViewForm; //This is used as the key for the dialog box
        public PXFilter<MSCustomerOrderDac> MSCustomerOrderViews; //This is used as teh key for the grid

        public PXAction<SOOrder> ViewCustomerOrders;
        [PXUIField(DisplayName = "View Custoemr", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
        [PXButton(Category = "Other")]
        [PXUIEnabled(typeof(Where<SOOrder.customerID.IsNotNull>))]
        protected virtual IEnumerable viewCustomerOrders(PXAdapter adapter)
        {
            MSCustomerOrderViews.AllowInsert=true;
            PXSelectBase<SOOrder> orders =
                    new PXSelectReadonly<SOOrder,
                    Where<SOOrder.customerID, Equal<Current<SOOrder.customerID>>>>(Base);


            foreach (SOOrder order in orders.Select())
            {
                MSCustomerOrderDac newOrder = new MSCustomerOrderDac();
                newOrder.OrderNumber = order.OrderNbr;
                newOrder.LineNbr = linenumber++;
                newOrder = MSCustomerOrderViews.Insert(newOrder);

            } //only inserts one thing, no good/


            if (MSCustomerViewForm.AskExt(true) != WebDialogResult.OK) //need this to show the form
            {
            }

            return adapter.Get();
        }

        // I might need to add a 
        [PXVirtual]
        [Serializable]
        [PXHidden]
        public class MSCustomerOrderDac : IBqlTable
        {

            #region OrderNumber 
            [PXString]
            [PXUIField(DisplayName = "Order Number")]
            public virtual String OrderNumber { get; set; }
            public abstract class orderNumber  : PX.Data.BQL.BqlString.Field<orderNumber> { }
            #endregion

            [PXInt(IsKey = true)]
            public virtual Int32? LineNbr { get; set; }
            public abstract class lineNbr : PX.Data.BQL.BqlInt.Field<lineNbr> { }



        }
    }

 

For the dialog box I haven’t done anything crazy, just defined the keys/skinid/ds/ and created controls for the orderNumber field.

Thanks in advance.

Best answer by Leonardo Justiniano

Hi @AidenMission 

Try also adding this code:

// This delegate overrides the database call
// first letter in lower case (Your view has it Upper case)
public IEnumerable mSCustomerOrderViews()
{
   return MSCustomerOrderViews.Cache.Cached;
}

Sorry I have been giving you the solution by drops. I Normally do both PXVirtualDAC and the delegate, specially in processing forms.

 

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

10 replies

Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

Hi @AidenMission 

Make sure your MSCustomerOrderDac has key columns. In your case you have LineNbr.

I suggest you do this small change in your code:

linenumber = 0;
foreach (SOOrder order in orders.Select())
{
   linenumber++;
   MSCustomerOrderViews.Current = MSCustomerOrderViews.Insert(new MSCustomerOrderDac() {LineNbr = linenumber});
   newOrder = MSCustomerOrderViews.Current;
   newOrder.OrderNumber = order.OrderNbr;
   MSCustomerOrderViews.Update(newOrder);
} 

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 25 replies
  • February 9, 2023

Hello @Leonardo Justiniano,

I thought that the [PXInt(IsKey=true) for the line number made that item a key column. Is there another attribute that I am supposed to use?

Also, I am sorry but I don't quite understand what you mean by “it might be both”, is it that I have the same issue as the thread that I linked + the key column issue? Or are you saying something else?

 

Thank you very much for your reply by the way  


Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

@AidenMission 

I made an editing. Can you please look at it? Thanks


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 25 replies
  • February 9, 2023

Thanks @Leonardo Justiniano,

I made the change specified but I still have the same issue. I’m starting to lean more on the side that I have something messed up in the ASPX config. I’ll update back here if I am able to fix it. Obviously if anyone has any suggestions please let me know!


Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

@AidenMission 

 

I just noticed that you have 

public PXFilter<MSCustomerOrderDac> MSCustomerOrderViews; 

PXFilter only handles 1 record. Please change that to PXSelect / SelectFrom


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 25 replies
  • February 9, 2023

@Leonardo Justiniano 

Thanks for pointing that out, I was unaware that PXFilter only handled one thing.

I tried changing it to PXSelect, but I think that since I am using a virtual table is it breaking. When I try to load in to SO3010PL I get an error saying:

Error: The entry form (ID: SO301000, title: Sales Orders) cannot be automated. Incorrect syntax near the keyword 'OPTION'.

I then tried SelectFrom but that seems to require a whole different way to add itemes to so I am going to need more time with it.

 


Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

Hi @AidenMission 

You have to mark the DAC as virtual to avoid going to the Database:

 

[PXVirtualDAC]
public PXSelect<MSCustomerOrderDac> MSCustomerOrderViews; 

 

Reference: Acumatica


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 25 replies
  • February 9, 2023

@Leonardo Justiniano,

Sorry but it’s still giving the same error of: Incorrect syntax near the keyword 'OPTION'.

Do you think I have to add a where clause? I’m not sure what it would be since I am building it after the fact. Or do I need to add some sort of key field in the DAC where I pull in the customer list there, I think there is something akin to that in the T-210 training.

I also did change it for testing to:

 [PXVirtualDAC]
public SelectFrom<MSCustomerOrderDac>.View MSCustomerOrderViews;

but it made no difference.

Thank you so much for the guidance by the way! 


Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

Hi @AidenMission 

Try also adding this code:

// This delegate overrides the database call
// first letter in lower case (Your view has it Upper case)
public IEnumerable mSCustomerOrderViews()
{
   return MSCustomerOrderViews.Cache.Cached;
}

Sorry I have been giving you the solution by drops. I Normally do both PXVirtualDAC and the delegate, specially in processing forms.

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 25 replies
  • February 9, 2023

@Leonardo Justiniano

Thank you that did the trick!!

And zero need to apologize! I appreciate your help a ton.

It makes sense, I’m still learning so I have no good basis of intuition for the best way to go about this. 

Also, I’m going to mark your last message as the answer but hopefully people read the whole chain


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