Skip to main content
Solved

Fields not showing data after Left Join


Forum|alt.badge.img

Hello Community;
I’m creating a form to retrieve Invoices and Memos infos and calculate some taxes,
I’m doing a Left join between ARInvoice table and MasterInvoice where master invoice is a table inherting from ARInvoice, like this : 

public class MasterInvoice : PX.Objects.AR.ARInvoice
{
}


SelectFrom<ARInvoice>
                .LeftJoin<Customer>.On<ARInvoice.customerID.IsEqual<Customer.bAccountID»
                .LeftJoin<MasterInvoice>.On<ARInvoice.masterRefNbr.IsEqual<MasterInvoice.refNbr»


The project is published successfully and the MasterInvoice fields are there, but those fields showing no data.

Any ideas?

Best answer by Dmitrii Naumov

There are several issue with this code.

  1. For ARInvoice the primary key is composite, consisting of DocType and RefNbr fields. So, to join tables you must always use both fields, not just RefNbr.
  2. If you take a look at the generated SQL for this request, you’ll see that it looks like ARInvoice.RefNbr = ARInvoice.RefNbr. It’s because the MasterInvoice.refNbr in C# is equivalent of  ARInvoice.refNbr. To make it different you need to redefine  refNbr in the MasterInvoice as the following 
    public class MasterInvoice : PX.Objects.AR.ARInvoice
    { 
        public new abstract class refNbr : PX.Data.BQL.BqlString.Field<refNbr> { } 
    }
  3. I’m not really sure why you need to join ARInvoice to itself.
View original
Did this topic help you find an answer to your question?

2 replies

Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • 629 replies
  • Answer
  • March 27, 2024

There are several issue with this code.

  1. For ARInvoice the primary key is composite, consisting of DocType and RefNbr fields. So, to join tables you must always use both fields, not just RefNbr.
  2. If you take a look at the generated SQL for this request, you’ll see that it looks like ARInvoice.RefNbr = ARInvoice.RefNbr. It’s because the MasterInvoice.refNbr in C# is equivalent of  ARInvoice.refNbr. To make it different you need to redefine  refNbr in the MasterInvoice as the following 
    public class MasterInvoice : PX.Objects.AR.ARInvoice
    { 
        public new abstract class refNbr : PX.Data.BQL.BqlString.Field<refNbr> { } 
    }
  3. I’m not really sure why you need to join ARInvoice to itself.

Forum|alt.badge.img
  • Author
  • Freshman I
  • 11 replies
  • March 29, 2024

Thank you for your help, Dimitri. the problem was solved.
I needed to join ARInvoice to itself to refer the splitted invoices ref nbr to the MasterRefNbr.


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