Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

How to deal with element.args().parmObject(); and process query on it

(0) ShareShare
ReportReport
Posted on by 205

Hello all,

Is there a way to deal with element.args().parmObject(); like we do with element.args().record(); ?

I'm explaining myself : 

I'm looking for some easy way to work with parmObject() between 2 forms, because parmObject() return an Object which i dont really find a way to process some query on it.

element.args().record() is more useful from my knowledge to filter records and work with recId for example.

So i m wondering how to deal with args.parmObject as easily as args.record.

Thank you for your answer.

  • Awaxx Profile Picture
    Awaxx 205 on at
    RE: How to deal with element.args().parmObject(); and process query on it

    yes its right

    the right code is :

    while (setEnum.moveNext())
            {
                selectMenus = setEnum.current();
                setOfRecIds.add(selectMenus.RecId);
                
                rangeStr = strFmt('((%1 == "%3") && (%2 == "%4"))',
                fieldStr(EukSecurityTreeNode, SecurableName),
                fieldStr(EukSecurityTreeNode, MatrixRole),
                queryValue(selectMenus.SecurableName),
                queryValue(selectMenus.EUKMatrixId));
    
                qbr = treeNodeQbds.addRange(fieldNum(EukSecurityTreeNode, MatrixRole));
                qbr.value(rangeStr);
                
            }

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to deal with element.args().parmObject(); and process query on it

    Hi,

    you forgot to mention what issues you have with it. As you can imagine, it's quite important that you tell what issues you have.

    Anyway I can right away see a mistake in your code. You seem to have missed it when debugging.

    In your while loop, you're reading records from the set and assigning them to selectMenus variable.

    But when you add ranges, you use field values from eukSelectMenus variable. I think you would rather want to use field values from selectMenus variable.

    while (setEnum.moveNext())
            {
                selectMenus = setEnum.current();
                setOfRecIds.add(selectMenus.RecId);
                
                rangeStr = strFmt('((%1 == "%3") && (%2 == "%4"))',
                fieldStr(EukSecurityTreeNode, SecurableName),
                fieldStr(EukSecurityTreeNode, MatrixRole),
                queryValue(eukSelectMenus.SecurableName),
                queryValue(eukSelectMenus.EUKMatrixId));
    
                qbr = treeNodeQbds.addRange(fieldNum(EukSecurityTreeNode, MatrixRole));
                qbr.value(rangeStr);
                
            }

  • Awaxx Profile Picture
    Awaxx 205 on at
    RE: How to deal with element.args().parmObject(); and process query on it

    Hi goshoom 

    public void init()
        {
    
            super();
            
            QueryBuildDataSource treeNodeQbds = EukSecurityTreeNode_ds.queryBuildDataSource();
    
            Set    selectedRecords = new Set(Types::Record);
    
            selectedRecords = element.args().parmObject();
    
            SetEnumerator setEnum = selectedRecords.getEnumerator(); // setOfRecords is the one i have
            Set setOfRecIds = new Set(Types::Int64);
            
            EUKSelectedMenus eukSelectMenus, selectMenus;
    
    
            while (setEnum.moveNext())
            {
                selectMenus = setEnum.current();
                setOfRecIds.add(selectMenus.RecId);
                
                rangeStr = strFmt('((%1 == "%3") && (%2 == "%4"))',
                fieldStr(EukSecurityTreeNode, SecurableName),
                fieldStr(EukSecurityTreeNode, MatrixRole),
                queryValue(eukSelectMenus.SecurableName),
                queryValue(eukSelectMenus.EUKMatrixId));
    
                qbr = treeNodeQbds.addRange(fieldNum(EukSecurityTreeNode, MatrixRole));
                qbr.value(rangeStr);
                
            }
    
        }

    Here is what i was trying in code.

    Thanksfully.

  • Martin Dráb Profile Picture
    Martin Dráb 230,569 Most Valuable Professional on at
    RE: How to deal with element.args().parmObject(); and process query on it

    Unfortunately this isn't a problem description that we can work with.

    If you need our help, please show us the code that you've written so far (for the iteration and query ranges) and then explain what problem you have with it.

  • Awaxx Profile Picture
    Awaxx 205 on at
    RE: How to deal with element.args().parmObject(); and process query on it

    nmaenpaa

    I tried but didnt get it ... :-(

    Thank you for all

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to deal with element.args().parmObject(); and process query on it

    Martin's reply shows how you can add many ranges to the data source query in a while loop.

    My reply in your other discussion shows how you can iterate a Set.

    By combining these two skills, you know how to iterate a set, and add ranges to a form data source query based on values in the set.

  • Awaxx Profile Picture
    Awaxx 205 on at
    RE: How to deal with element.args().parmObject(); and process query on it

    nmaenpaa

    Thank you for that point.

    Maybe i didnt explained it correctly. Martin showed me the best way to do it and i will use it each time it neeeded.

    But just for my training i was trying to do it in other way and i m understanding that's confuse.

    Step 3 didnt worked for me and i dont know why or how to do it correctly.

    But i will come back to the way Martin showed me.

    Thank you guys for you time.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to deal with element.args().parmObject(); and process query on it

    args.parmObject() is just a way to pass an object from one place to another. Once it's passed, then we can completely ignore it.

    I think you need to think these processes step by step. Focus on one step at a time, and once it works, move to the next step. This way you know that we don't have anything to discuss regarding parmObject here.

    1) Pass a Set from form A to form B (this you already did so we don't need to care about it anyore)

    2) Iterate a Set (this you know how to do)

    3) Add ranges to the form data source query via x++ code (this is what Martin has demonstrated in the other discussion)

    But, as Martin demonstrated in the other discussion, you don't even need to pass any sets / objects between these forms. So actually steps 1 and 2 are irrelevant for solving your business requirement. You simply need to access the data source of form A from form B, and use the selected records of form A to filter the data source of form B. How do do this has been shared by Martin in that other discussion.

  • Awaxx Profile Picture
    Awaxx 205 on at
    RE: How to deal with element.args().parmObject(); and process query on it

    I tried to do it with the same process but didnt reach the result i expect.

    I found many ways to do it when using args.record but no one to do it with args.parmObject

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to deal with element.args().parmObject(); and process query on it

    Hi,

    .record() or parmObject() have absolutely no impact on how you filter a form data source. Therefore you can apply the things you learned in the other discussion from Martin (community.dynamics.com/.../how-to-deal-with-multiselecthelper-on-clicked-event).

    As you learned in that discussion, you don't use select statements when working with form data sources. Instead you have to add ranges to the data source query.

    Perhaps you should continue the discussion there, since it seems we're now discussing the same topic in two places. Which just makes it confusing for you and us (information is scattered).

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,885 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,569 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans