web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

When I selecting multiple Record on FormA Its related records shown on FormB's Grid is Empty

(0) ShareShare
ReportReport
Posted on by 256

I have two form. I.e. FormA and FormB. In FormB is attached with a view. [we have used multiple table relations so I use view].

When I select FormA Multiple Record on button click then its related data it has shown on FormB. But It displays Blank Grid of Form. 

Form A [MenuItem Click Method]

void clicked()
{
    int         recordCount;
    HcmWorker   hcmWorkerbuff;
    container   con;
    Args        args;
    str         multiselectstring;
  //  super();
    args            = new Args();
    recordCount     = HcmWorker_ds.recordsMarked().lastIndex();
    hcmWorkerbuff   = HcmWorker_ds.getFirst(1);

    while(hcmWorkerbuff)
    {
        con                 = conIns(con,1,hcmWorkerbuff.PersonnelNumber);
        multiselectstring   = con2Str(con,',');
        hcmWorkerbuff       = HcmWorker_ds.getNext();
    }

    args.parm(multiselectstring);
    new MenuFunction(menuitemDisplayStr(STBankDetailsDemo), MenuItemType::Display).run(args);
}


FormB [Init method]

public void init()
{
    container       con;
    int             i;
    str             multiRecord;

    super();

    multiRecord     = element.args().parm();

    con             = str2con(multiRecord,',');

    for(i = 1; i<=conLen(con);i++)
    {
        STViewBankDetailsDemo_ds.query().dataSourceTable(tableNum(STViewBankDetailsDemo)).addRange(fieldNum(STViewBankDetailsDemo,PersonnelNumber)).value(SysQuery::value(conPeek(con,i)));
    }
}


Scr2.png

*This post is locked for comments

I have the same question (0)
  • NeoMatrix Profile Picture
    256 on at
    RE: When I selecting multiple Record on FormA Its related records shown on FormB's Grid is Empty

    Yes. It working Perfectly.

    Thanks For Reply.

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: When I selecting multiple Record on FormA Its related records shown on FormB's Grid is Empty

    From the infolog we can finally see the actual problem. It tries to look for 51, but there is not such record. Instead there is 0000051 which is a completely different thing (remember these are string fields, not numbers).

    It seems that the leading zeros get lost in the default behavior of the str2con function.

    It will be fixed if you add "false" as the third parameter of the call, to prevent it from trying to convert our string into a number (and losing the leading zeros).

    So in the place in your code where you read the container from the args, use this syntax:

    str2con(element.args().parm(), ',', false);


    Now it should work.

    Also your previous error should be gone since now we get strings out from the container, not numbers.

    However if you still get the error about invalid value, please discard the latest change from executeQuery method.

  • NeoMatrix Profile Picture
    256 on at
    RE: When I selecting multiple Record on FormA Its related records shown on FormB's Grid is Empty

    Yes. PersonnelNumber is 0000051 or 0000052.

    When I put the code it gives error

    Error executing code: QueryBuildRange (object), method value called with invalid parameters.
    Stack trace
    (C)\Classes\QueryBuildRange\value
    (C)\Forms\STDisplayDemoForm\Data Sources\STViewBankDetailsDemo\Methods\executeQuery - line 11
    (C)\Classes\FormRun\run
    (C)\Classes\xMenuFunction\run
    (C)\Classes\MenuFunction\run - line 85
    (C)\Forms\STSelectDemoForm\Designs\DesignList\MenuItemButton\Methods\Clicked - line 19

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: When I selecting multiple Record on FormA Its related records shown on FormB's Grid is Empty

    Do you have records in STViewBankDetailsDemo where PersonnelNumber is 51 or 52?

    One more thing you could try is to edit the code where you add the query range:

    STViewBankDetailsDemo_ds.query().dataSourceTable(tableNum(STViewBankDetailsDemo)).addRange(fieldNum(STViewBankDetailsDemo,PersonnelNumber)).value(conPeek(con,i));


  • NeoMatrix Profile Picture
    256 on at
    RE: When I selecting multiple Record on FormA Its related records shown on FormB's Grid is Empty

    It show like

    SELECT FIRSTFAST * FROM STViewBankDetailsDemo(STViewBankDetailsDemo) WHERE ((PersonnelNumber = N'52') OR (PersonnelNumber = N'51'))

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: When I selecting multiple Record on FormA Its related records shown on FormB's Grid is Empty

    And what does this.query().toString() tell you?

  • NeoMatrix Profile Picture
    256 on at
    RE: When I selecting multiple Record on FormA Its related records shown on FormB's Grid is Empty

    It selects the value and also store , but it display empty form grid

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: When I selecting multiple Record on FormA Its related records shown on FormB's Grid is Empty

    Now I noticed that in the clicked method you are using:

    conIns(con,1,hcmWorkerbuff.PersonnelNumber);

    This call doesn't insert anything to "con", instead it creates a new container and returns it. But you are not storing it anywhere.

    Instead you should be using (like I already instructed):

    con += hcmWorkerBuff.PersonnelNumber;

    Or

    con = conIns(con,1,hcmWorkerbuff.PersonnelNumber);

    If you are asking for very detailed instructions, please try to follow them.

  • NeoMatrix Profile Picture
    256 on at
    RE: When I selecting multiple Record on FormA Its related records shown on FormB's Grid is Empty

    Yes. STViewBankDetailsDemo.PersonnelNumber field contain values that correspond with HcmWorker.PersonnelNumber [both table field having same value] and it show below result

    STViewBankDetailsDemo.PersonnelNumber field contain values that correspond with HcmWorker.PersonnelNumber

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: When I selecting multiple Record on FormA Its related records shown on FormB's Grid is Empty

    Does your STViewBankDetailsDemo.PersonnelNumber field contain values that correspond with HcmWorker.PersonnelNumber? If not, you will obviously not get any results.

    What if you add the following line before the super() call in the executeQuery. Could you provide the result here, please.

    info(this.query().toString());


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans