0

I had this code:

[DataSource]
    class FiscalDocument_BR
    {
        public void init()
        {
            super();

            this.query().dataSourceTable(tableNum(FiscalDocument_BR)).clearDynalinks();

            this.query().dataSourceTable(tableNum(FiscalDocument_BR)).addDynalink(
                fieldNum(FiscalDocument_BR, Voucher),
                GeneralJournalEntry,
                fieldNum(GeneralJournalEntry, SubledgerVoucher));
        }

    }

But the client found a potential bug and I had to change this query to work like something like (this query works as intended):

SELECT * FROM GeneralJournalEntry
INNER JOIN FiscalDocument_BR ON 
    GeneralJournalEntry.SUBLEDGERVOUCHER = FiscalDocument_BR.VOUCHER OR
    GeneralJournalEntry.SUBLEDGERVOUCHER = FiscalDocument_BR.InventoryVoucher OR
    GeneralJournalEntry.SUBLEDGERVOUCHER = FiscalDocument_BR.CancelVoucherId OR
    GeneralJournalEntry.SUBLEDGERVOUCHER = FiscalDocument_BR.CancelInventoryVoucherId 
WHERE SUBLEDGERVOUCHER IN ('E001-20001314', 'E001-10020552')

I haven't found a option to use dynalink with multiple parameters and using dynalink multiple times is also not working since I need to use "OR" operator.

I've also tried to use range with no success:

    [DataSource]
    class FiscalDocument_BR
    {
        public void init()
        {
            super();

            this.query().dataSourceTable(tableNum(FiscalDocument_BR)).addRange(Fieldnum(FiscalDocument_BR, RecId)).value(
                strFmt('((%1.%2 == %3.%4) || (%1.%2 == %3.%5) || (%1.%2 == %3.%6) || (%1.%2 == %3.%7))'
                , this.query().dataSourceTable(tablenum(GeneralJournalEntry)).name()//1
                , fieldStr(GeneralJournalEntry, SubledgerVoucher)//2
                , this.query().dataSourceTable(tablenum(FiscalDocument_BR)).name()//3
                , fieldStr(FiscalDocument_BR, Voucher)//4
                , fieldStr(FiscalDocument_BR, InventoryVoucher)//5
                , fieldStr(FiscalDocument_BR, CancelVoucherId)//6
                , fieldStr(FiscalDocument_BR, CancelInventoryVoucherId)));//7
        }

    }

How can I edit this code in order to replicate this sql query?

Thanks in advance.

FH-Inway
  • 4,432
  • 1
  • 20
  • 37
Emanuel Hiroshi
  • 318
  • 1
  • 7
  • Did you check what SQL query the code from your range attempt generates? At first glance it looks like it should generate something similar to the SQL query. – FH-Inway May 18 '23 at 05:06
  • In the range attempt, did you try clearing the dynalinks first (like in the original code) before setting the range? – FH-Inway May 18 '23 at 05:11
  • The SQL created using "this.query().getSQLStatement()" resulted in a correct query, but when I clicked in the form, information and tried to check on it, it hadn't any reference to my range. Also, in one of my many atempts I had a clearDynalinks call just like the original code. – Emanuel Hiroshi May 18 '23 at 11:23

0 Answers0