How to resolve "Error: 'OrderDate' cannot be empty" in my custom screen
Hi,
I have a newly created screen including a form and grid. I have modified a button to pop-up a window which consists data of POOrder and POLine tables. To load data from these two tables, I have defined a view like below.
public SelectFrom<POLine> .InnerJoin<POOrder>.On<POLine.orderNbr.IsEqual<POOrder.orderNbr> .And<POLine.orderType.IsEqual<POOrder.orderType>>> .View POrdersView;
I want to add some values from this smart panel to my custom grid in the screen. After adding the values to the grid, when I try to save to the database, I’m getting below error.
There is no field called ‘OrderDate’ in my DAC for the grid, but both POOrder and POline have ‘OrderDate’. Even I don’t try to update records in these two tables, How can I get this error? Does someone have an idea on how to solve this?
thank you
Page 1 / 1
If you are only using the POOrder and POLine as references for data to view only, try using SelectFrom<>.View.ReadOnly to define your view. That should not allow any record updates at all to happen, so if something behind the scenes is changing the order date, it shouldn’t be able to if the view is defined like that.
Hi @oshadarodrigo64 Can you please share the source code (DAC and Graph files), so that we can review and help you if we can found something strange?
Hi @Naveen Boga ,
Ok , I will share with you .
Hi ,
I have defined the view like this now.
public PXSelectReadonly2<POLine, InnerJoin<POOrder,On<POLine.orderNbr,Equal<POOrder.orderNbr>, And<POLine.orderType, Equal<POOrder.orderType>>>>, Where<POLine.vendorID, Equal<Current<APProforma.customerID>>>> POrdersView;
After defining the view like above, I’m not able to select one by one, but when I click add-close button all the values are added and can be saved without getting the ‘OrderDate cannot be empty error’.
I think this is happening because of using the PXselectReadonly attribute as it creates a read-only view . I have taken the selected feild from POLine dac to allow user to select the value. So how Can I enable editable only to the one feild (selected) to allow check it.? below I mentioned a method that I have attempted but it didn’t work as it is.
I did not picture that’s how you are using it. You won’t be able to use the read only for that case.
What is the logic you are using when adding the selected items from the smart panel to the grid?
Hi @epetruncio89 ,
for the smart panel I need to load data from both POLine and POOrder. for that I have defined the view using PXSelectReadonly2 attribute to avoid ‘OrderDate cannot be empty error’. now the error is gone when saving the added data in the grid to the database. but my issue is I cannot select and add one by one from smart panel because i’m not allowed to select the check box there. Instead of that, when I select add button in the smart panel, all the available values are added to the grid. To allow user to select one value, I have added the field ‘selected’ of POLine. so I thought that I’m getting this issue because I have a read-only view, so I thought of trying to change only the specific field ‘selected’ to set editable, but I don’t know whether it is correct or wrong, However I have put the whole code of the graph for your reference.
namespace GRIProformaInvoice.Extension { // Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active public class APProformaEntry_Extension : PXGraphExtension<APProformaEntry> {
public PXSelectReadonly2<POLine, InnerJoin<POOrder,On<POLine.orderNbr,Equal<POOrder.orderNbr>, And<POLine.orderType, Equal<POOrder.orderType>>>>, Where<POLine.vendorID, Equal<Current<APProforma.customerID>>>> POrdersView;
public virtual IEnumerable InsertSelectedLines(PXAdapter adapter) { if (POrdersView != null) { int lineNbr = Base.APProformaItems.Select().Count + 1; foreach (PXResult< POLine, POOrder> result in POrdersView.Select()) { POOrder order = result; POLine line = result;
but this time I’m getting the same error - ‘OrderDate cannot be empty’ again when saving to the database, attempted many approaches but still couldn’t find the solution.
You should remove the PXReadOnly and replace it with your original code you had in place. I did not realize you were using that smart panel to select lines to add like that. You won’t be able to do it with the view defined using PXReadOnly. I strongly advise you revert to your original code. I am looking into the code you provided now.
I’m looking into the code and I cannot find the view “APProformaItems.” I am trying to find that to see what DAC it references. My suspects are that those DAC items might contain a field labeled “Order Date” that might be required to be populated. My suggestion would be to see if there is a date, and if so, populate it using the order date from the purchase order.
If that isn’t the case, can you provide where I can find the APProformaItems view?