Sunday, May 18, 2014

Pass multiple records from one form to another

I came across a requirement to pass multiple records from one form to another. It might would be a very common practice now. However, I thought to blog it for if anyone still not cleat with this part.


Instead of passing datasource as an argument in the property, Override clicked() method of button and prepare your args to pass as shown. I am taking an example of SalesTable to pass to another form

void clicked()
{
    int         recordsCount;
    SalesTable  salesTable;
    container   con;
    Args        args;
    str         multiSelectString;

    args = new Args();
    // gets the total records selected
    recordsCount = salesTable_ds.recordsMarked().lastIndex();
    salesTable= salesTable_ds.getFirst(1);

    while (salesTable)
    {
        // storing recid of selected record in container
        con = conIns(con,1, salesTable.RecId);

        // converting container to string with comma separated
        multiSelectString = con2Str(con,’,’);

        salesTable= SampleTable_ds.getNext(); // moves to next record
    }
   
    // passing string
    args.parm(multiSelectString);
    // calling menu item
    new MenuFunction(menuitemDisplayStr(NewFormMenuItem), MenuItemType::Display).run(args);
}

Now in the above method we have already prepared our args in a container and have passed that to a new form of menu item "NewFormMenuItem"

In order to retrieve passed arguments in the recipient from. Override the init() method of new form as shown

public void init()
{
    container   con;
    int         i;
    str         multipleRecords;
   
    super();
   
    // to get string value from caller
    multipleRecords = element.args().parm();

    // string to container
    con = str2con(multipleRecords,”,”);

    // for sorting
    for(i = 1;i<= conLen(con) ;i++)
    {
        salesTable_ds.query().dataSourceTable(Tablenum(SalesTable)).addRange(fieldNum(SalesTable,RecId)).value(SysQuery::value(conPeek(con,i)));
    }
} 

If you have some more improved versions of this task please share.
Happy DAXing!

6 comments:

Saurabh said...

I would not suggest changing the container to String, as string has several limitations. Instead, I would use parmObject method, as it is done here http://daynamicsaxaptatutorials.blogspot.in/2011/10/parmobject-with-containerargscontainer.html

Unknown said...

babyliss, insanity workout, mac cosmetics, hollister, converse outlet, hollister, valentino shoes, giuseppe zanotti, louboutin, reebok shoes, nike roshe, beats by dre, gucci, new balance, bottega veneta, nike air max, longchamp, soccer jerseys, north face outlet, ghd, nike trainers, chi flat iron, celine handbags, asics running shoes, jimmy choo shoes, nike huarache, lululemon, nike air max, ferragamo shoes, vans, wedding dresses, birkin bag, mcm handbags, mont blanc, abercrombie and fitch, baseball bats, instyler, ray ban, converse, oakley, p90x workout, timberland boots, iphone cases, north face outlet, hollister, herve leger, soccer shoes, nfl jerseys, vans shoes, ralph lauren

Unknown said...

ugg,ugg australia,ugg italia, supra shoes, barbour, pandora charms, montre pas cher, moncler, canada goose, canada goose outlet, lancel, louis vuitton, sac louis vuitton pas cher, moncler, pandora charms, swarovski crystal, wedding dresses, ugg boots uk, pandora jewelry, replica watches, moncler, canada goose uk, juicy couture outlet, coach outlet, links of london, canada goose, canada goose outlet, doudoune canada goose, canada goose, barbour jackets, bottes ugg, swarovski, moncler outlet, marc jacobs, moncler, louis vuitton, canada goose, hollister, toms shoes, moncler, ugg pas cher, moncler, karen millen, louis vuitton, pandora jewelry, ugg,uggs,uggs canada, moncler, louis vuitton, juicy couture outlet, thomas sabo

yanmaneee said...

yeezy boost 700
michael kors outlet
jordan shoes
michael kors outlet online
lebron 10
cheap mlb jerseys
lebron 11
yeezy boost
fila shoes
reebok outlet

Anonymous said...

jordan shoes
kyrie 7
irving shoes
off white jordan 1
hermes handbags
kyrie irving shoes
palm angels tracksuit
palm angels outlet
jordan 1 mid
kyrie shoes

Anonymous said...

goyard
kevin durant shoes
bape
yeezy
off white
nike off white
golden goose outlet
kd 12 shoes
kd shoes
supreme official