Monday, November 28, 2022

How to fetch records to Include filter values using x++

 Hi guys, I have a requirement to fetch the record to include filed values from the report dialog.

I need to show those values in the report footer.

 Code :

        str                         value;
        Query                       query = New Query();
        QueryBuildDataSource        qbds;
        QueryBuildRange             qbr;
        int                         totalDS, totalRanges;
        QueryFilter                 qf;

        query             = qr.query();// getting query from query run.
        totalDS           = query.dataSourceCount();

        int  cnt = query.queryFilterCount();

        // Fetching data from query if any new tables are joined or new Fileds are added
        for (int ds =1; ds<= cnt; ds++)
        {
            qf = query.queryFilter(ds);

            if(qf.value())
            {
                value += strFmt('%1 : %2   ',
                                qf.field(),
                                qf.value());
            }
        }

        // Used to fectch data from the standard view query 
        for (int ds =1; ds<= totalDS; ds++)
        {
            qbds            = query.dataSourceNo(ds);
            totalRanges     = qbds.rangeCount();

            for (int r =1; r<= totalRanges; r++)
            {
                qbr =  qbds.range(r);
                if (qbr.value())
                {
                    // Way 1 : 
                    // qbr.prompt();
                    value += strFmt('%1 : %2  ',
                                       qbr.prompt(),
                                        qbr.value());

                    // Way2 :
                    TableId     tableId =  qbds.table();//tableName2Id(qbds.AOTname());
                    DictTable   dictTable = new SysDictTable(tableId);

                    str fieldname = qbr.AOTname();

                    if(qbr.value())
                    {
                        MiscParameters += strFmt('%1 : %2  ',
                                      dictTable.fieldObject(fieldName2Id(tableId, qbr.fieldName())).label(),
                                qbr.value());
                       
                    }

                    // Way3 :
                    // Direct Field
                    FieldId  fieldId = qbr.field();
                    if(qbr.value())
                    {
                        MiscParameters += strFmt('%1 : %2  ',
                                      dictTable.fieldObject(fieldId).label(),
                                qbr.value());
                              
                    }

                    // Way4 :
                    str     value = strFmt('%1', qbr.value());
                    Map     miscParametersMap = new Map(Types::String, Types::String);// Write this line at out side of loop

                    if (value)
                    {
                        if (miscParametersMap.exists(qbr.prompt()))
                        {
                            container   con = str2con(miscParametersMap.lookup(qbr.prompt()), ',' , false);

                            if (!conFind(con, value))
                            {
                                con += value;
                            }

                            miscParametersMap.insert(qbr.prompt(), con2Str(con));
                        }
                        else
                        {
                            miscParametersMap.insert(qbr.prompt(), value);
                        }
                    }

                    if (miscParametersMap.elements())
                    {
                        MapEnumerator   mapEnumerator = miscParametersMap.getEnumerator();

                        while (mapEnumerator.moveNext())
                        {
                            value += (strfmt("%1 : %2  ",
                                        mapEnumerator.currentKey(),
                                        mapEnumerator.currentValue()));
                        }
                    }

                }
            }
        }


Keep Daxing!!

Thursday, November 17, 2022

Display the currency sign in Report

 Hi guys, Today I got the requirement to showcase the currency symbol in the report after that amount based on currency.

Below is the path for currency symbol.

General Ledger -> Currency -> Currencies form

For getting this 

  • I have created a new field in the temp table.
  • I have added the below code in the DP class.

myTemptable.Symbol = Currency::find(myTempTable.CurrencyCode).Symbol;


After that, I added the below expression in the report Design. (Anyone we can use)

=Format(Fields!Amount.Value, "N2") & space(1) & Fields!CurrencySymbol.Value
=Format(Fields!Amount.Value & " " & Fields!CurrencySymbol.Value)



Keep Daxing!!