Sunday, April 11, 2021

Query run with dynamic ranges

public Query getQueryOrderHoldRules()
    {
        Query                   query;
        QueryBuildDataSource    qbdsMCRHoldCodeTable;

        query = new Query();

        qbdsMCRHoldCodeTable = query.addDataSource(tableNum(MCRHoldCodeTable));

        switch (documentStatus)
        {
            case CredManDocumentStatusCheck::Confirmation:
                qbdsMCRHoldCodeTable.addRange(fieldNum(MCRHoldCodeTable, SAZConfirmation)).value(SysQuery::value(NoYes::Yes));
                break;
            case CredManDocumentStatusCheck::PickingList:
                qbdsMCRHoldCodeTable.addRange(fieldNum(MCRHoldCodeTable, SAZPickingList)).value(SysQuery::value(NoYes::Yes));
                break;
            case CredManDocumentStatusCheck::PackingSlip:
                qbdsMCRHoldCodeTable.addRange(fieldNum(MCRHoldCodeTable, SAZPackingSlip)).value(SysQuery::value(NoYes::Yes));
                break;

            case CredManDocumentStatusCheck::WHSShipment:
                qbdsMCRHoldCodeTable.addRange(fieldNum(MCRHoldCodeTable, SAZWHSShipment)).value(SysQuery::value(NoYes::Yes));
                break;

            case CredManDocumentStatusCheck::Invoice:
                qbdsMCRHoldCodeTable.addRange(fieldNum(MCRHoldCodeTable, SAZInvoice)).value(SysQuery::value(NoYes::Yes));
                break;

            default:
                break;
        }

        qbdsMCRHoldCodeTable.addRange(fieldNum(MCRHoldCodeTable, SAZHoldCodeRule)).value(SysQuery::valueNot(SAZHoldCodeRule::None));

        return query;

    }

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8