X++ passing current selected records in a form for your report
Asked Answered
E

3

5

I am trying to make this question sound as clear as possible.

Basically, I have created a report, and it now exists as a menuitem button so that the report can run off the form.

What I would like to do, is be able to multi-select records, then when I click on my button to run my report, the current selected records are passed into the dialog form (filter screen) that appears.

I have tried to do this using the same methods as with the SaleLinesEdit form, but had no success.

If anyone could point me in the right direction I would greatly appreciate it.

Elroyels answered 4/4, 2012 at 15:21 Comment(0)
E
2

Here is the resolution I used for this issue;

Two methods on the report so that when fields are multi-selected on forms, the values are passed to the filter dialog;

private void setQueryRange(Common _common)
    {
    FormDataSource              fds;

    LogisticsControlTable       logisticsTable;

    QueryBuildDataSource        qbdsLogisticsTable;
    QueryBuildRange             qbrLogisticsId;
    str                         rangeLogId;

    set                         logIdSet    = new Set(Types::String);

    str addRange(str _range, str _value, QueryBuildDataSource _qbds, int _fieldNum, Set _set    =       null)
    {
        str             ret = _range;
        QueryBuildRange qbr;
        ;

        if(_set && _set.in(_Value))
        {
            return ret;
        }

        if(strLen(ret) + strLen(_value) + 1 > 255)
        {
            qbr = _qbds.addRange(_fieldNum);
            qbr.value(ret);
            ret = '';
        }

        if(ret)
        {
            ret += ',';
        }

        if(_set)
        {
            _set.add(_value);
        }

        ret += _value;
        return ret;
    }
    ;

    switch(_common.TableId)
    {
        case tableNum(LogisticsControlTable):

            qbdsLogisticsTable = element.query().dataSourceTable(tableNum(LogisticsControlTable));
            qbrLogisticsId     = qbdsLogisticsTable.addRange(fieldNum(LogisticsControlTable, LogisticsId));

            fds = _common.dataSource();

            for(logisticsTable = fds.getFirst(true) ? fds.getFirst(true) : _common;
                logisticsTable;
                logisticsTable = fds.getNext())
            {
                rangeLogId = addrange(rangeLogId, logisticsTable.LogisticsId, qbdsLogisticsTable, fieldNum(LogisticsControlTable, LogisticsId),logIdSet);
            }

            qbrLogisticsId.value(rangeLogId);
            break;
    }
}

// This set the query and gets the values passing them to the range i.e. "SO0001, SO0002, SO000£...

The second methods is as follows;

private void setQueryEnableDS()
{
    Query           queryLocal = element.query();
    ;
}

Also on the init method this is required;

public void init()
{
    ;
    super();

    if(element.args() && element.args().dataset())
    {
        this.setQueryRange(element.args().record());
    }
}

Hope this helps in the future for anyone else who has the issue I had.

Elroyels answered 10/4, 2012 at 12:38 Comment(0)
M
3

Take a look at Axaptapedia passing values between forms. This should help you. You will probably have to modify your report to use a form for the dialog rather than using the base dialog methods of the report Here is a good place to start with that!

Meakem answered 4/4, 2012 at 18:16 Comment(1)
Thank you Michael, I appreciate your help and will begin working on this straight away.Elroyels
L
3

Just wanted to add this

You can use the MuliSelectionHelper class to do this very simply:

MultiSelectionHelper selection = MultiSelectionHelper::createFromCaller(_args.caller());
MyTable myTable = selection.getFirst();
while (myTable)
{
    //do something
    myTable = selection.getNext();
} 
Lander answered 30/1, 2013 at 20:3 Comment(0)
E
2

Here is the resolution I used for this issue;

Two methods on the report so that when fields are multi-selected on forms, the values are passed to the filter dialog;

private void setQueryRange(Common _common)
    {
    FormDataSource              fds;

    LogisticsControlTable       logisticsTable;

    QueryBuildDataSource        qbdsLogisticsTable;
    QueryBuildRange             qbrLogisticsId;
    str                         rangeLogId;

    set                         logIdSet    = new Set(Types::String);

    str addRange(str _range, str _value, QueryBuildDataSource _qbds, int _fieldNum, Set _set    =       null)
    {
        str             ret = _range;
        QueryBuildRange qbr;
        ;

        if(_set && _set.in(_Value))
        {
            return ret;
        }

        if(strLen(ret) + strLen(_value) + 1 > 255)
        {
            qbr = _qbds.addRange(_fieldNum);
            qbr.value(ret);
            ret = '';
        }

        if(ret)
        {
            ret += ',';
        }

        if(_set)
        {
            _set.add(_value);
        }

        ret += _value;
        return ret;
    }
    ;

    switch(_common.TableId)
    {
        case tableNum(LogisticsControlTable):

            qbdsLogisticsTable = element.query().dataSourceTable(tableNum(LogisticsControlTable));
            qbrLogisticsId     = qbdsLogisticsTable.addRange(fieldNum(LogisticsControlTable, LogisticsId));

            fds = _common.dataSource();

            for(logisticsTable = fds.getFirst(true) ? fds.getFirst(true) : _common;
                logisticsTable;
                logisticsTable = fds.getNext())
            {
                rangeLogId = addrange(rangeLogId, logisticsTable.LogisticsId, qbdsLogisticsTable, fieldNum(LogisticsControlTable, LogisticsId),logIdSet);
            }

            qbrLogisticsId.value(rangeLogId);
            break;
    }
}

// This set the query and gets the values passing them to the range i.e. "SO0001, SO0002, SO000£...

The second methods is as follows;

private void setQueryEnableDS()
{
    Query           queryLocal = element.query();
    ;
}

Also on the init method this is required;

public void init()
{
    ;
    super();

    if(element.args() && element.args().dataset())
    {
        this.setQueryRange(element.args().record());
    }
}

Hope this helps in the future for anyone else who has the issue I had.

Elroyels answered 10/4, 2012 at 12:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.