Skip to main content

Notifications

Announcements

No record found.

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

Pass parameter to display method which is added to lookup method. Is it possible?

Posted on by 56

Hello!

Is it possible to pass paramater to display method which is added to lookup!

pastedimage1644913008806v1.png

And my display method:

pastedimage1644913057153v2.png

I need to pass specific date to this method, to dislpay correct values? Is it even possible this way?

Kind regards,

Maris

  • Maris Sausins Profile Picture
    Maris Sausins 56 on at
    RE: Pass parameter to display method which is added to lookup method. Is it possible?

    Sorry I wan't clear enough, I don't have problem with this line 

    PRMOrderLines.lookupActivePositions(_formControl, PRMOrderLines.AssumedDate); 

    But thanks for the  tip about static method. 

    I'm having problem with the method added to lookup

    sysMultiTableLookup.addLookupMethod(tableMethodStr(PRMPosDepart, positionsAvailable));

    positionsAvailable method have input parameter _onDate:

    [SysClientCacheDataMethodAttribute(true)]
    public display PrmPositionsAvailable positionsAvailable(PRMDate _onDate = systemDateGet())
    {
        PrmPositionsAvailable  available;
        ;
    
        available = this.PosEmpCount - this.PositionsUsed(_onDate);
    
        return available;
    }

    And I can't figure out how to pass date parameter to this method

    Again sorry for missdirection.

    Kind regards 

    Maris

  • Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,421 on at
    RE: Pass parameter to display method which is added to lookup method. Is it possible?

    Hi Maris,

    Lookup methods should be static methods. You can look at existing methods in InventTable. Please check the lookupItem method as an example. You should be able to pass dates into the lookup method. So the call from the data source lookup method will look like this

    PRMOrderLines::lookupActivePositions(_formControl, PRMOrderLines.AssumedDate); 

    I am not sure why you are trying to call the write function in the lookup method.

  • Maris Sausins Profile Picture
    Maris Sausins 56 on at
    RE: Pass parameter to display method which is added to lookup method. Is it possible?

    Sorry for late response, got carried away with more pressing matters.

    MuthuAXTech, sorry I still don't get how can I pass the paramter to lookup added method.

    Hi Gunjan!

    Thanks for your reply! I will try to explain what I want to achieve:

    I created a  custom lookup in orderlines table(custom model):

    public void lookupActivePositions(FormControl _lookupCtrl, PrmDate _startDate)
    {
        SysMultiTableLookup     sysMultiTableLookup;
        Query                   query;
        QueryBuildDataSource    qbds, posDepQbds;
        PRMGetPosEmpCount       PRMGetPosEmpCount = PRMParameters::find().GetPosEmpCount;
    
        query = new Query();
        qbds = query.addDataSource(tableNum(PRMPosition));
        qbds.clearRanges();
    
        switch(PRMGetPosEmpCount)
        {
            case PRMGetPosEmpCount::PosDepart:
                posDepQbds = qbds.addDataSource(tableNum(PRMPosDepart));
                posDepQbds.clearRanges();
                posDepQbds.addRange(fieldNum(PRMPosDepart, DepartId)).value(SysQuery::value(this.DepartId));
                posDepQbds.addRange(fieldNum(PRMPosDepart, StartDate)).value(strFmt("..%1", SysQuery::value(_startDate)));
                //posDepQbds.addRange(fieldNum(PRMPosDepart, EndDate)).value(strFmt("1%, %2..", SysQuery::valueEmptyString(), SysQuery::value(this.Start)));
                posDepQbds.addRange(fieldNum(PRMPosDepart, EndDate)).value(queryvalue(dateNull()));
                posDepQbds.addRange(fieldNum(PRMPosDepart, EndDate)).value(strFmt("%1..", SysQuery::value(_startDate)));
                posDepQbds.addLink(fieldNum(PRMPosition, PositionId), fieldNum(PRMPosDepart, PositionId));
                posDepQbds.joinMode(JoinMode::ExistsJoin);
                qbds.addRange(fieldNum(PRMPosition, Start)).value(strFmt("..%1", SysQuery::value(this.Start)));
                qbds.addRange(fieldNum(PRMPosition, End)).value(queryvalue(dateNull()));
                qbds.addRange(fieldNum(PRMPosition, End)).value(strFmt("%1..", SysQuery::value(_startDate)));
                break;
            default:
                qbds.addRange(fieldNum(PRMPosition, Start)).value(strFmt("..%1", SysQuery::value(_startDate)));
                qbds.addRange(fieldNum(PRMPosition, End)).value(queryvalue(dateNull()));
                qbds.addRange(fieldNum(PRMPosition, End)).value(strFmt("%1..", SysQuery::value(_startDate)));
                break;
        }
    
    
        sysMultiTableLookup = SysMultiTableLookup::newParameters(_lookupCtrl, query);
    
        sysMultiTableLookup.addLookupfield(fieldNum(PRMPosition, PositionId));
        sysMultiTableLookup.addLookupfield(fieldNum(PRMPosition, Name));
        if(PRMGetPosEmpCount == PRMGetPosEmpCount::PosDepart)
        {
            sysMultiTableLookup.addLookupMethod(tableMethodStr(PRMPosDepart, positionsAvailable));
        }
        else
        {
            sysMultiTableLookup.addLookupMethod(tableMethodStr(PRMPosition, positionsAvailable));
        }
    
        qbds.addSortField(fieldNum(PRMPosition, PositionId), SortOrder::Ascending);
    
        sysMultiTableLookup.parmQuery(query);
        sysMultiTableLookup.performFormLookup();
    
    }

    I have forms ( example of one form) :

    pastedimage1645007528424v1.png

    With 3 DS, On PrmOrderlines_DS field control I have overidden lookup method:

    pastedimage1645007674192v2.png

    Lookup method: 

    public void lookup(FormControl _formControl, str _filterStr)
    {
        PRMGetPosEmpCount       PRMGetPosEmpCount = PRMParameters::find().GetPosEmpCount;
       
        if(PRMGetPosEmpCount::PosDepart && !PRMOrderLines.DepartId)
        {
            error("@PRM7912");
            return;
        }
    
        if(!PRMOrderLines.AssumedDate)
        {
            error("@PRM7913");
            return;
        }
    
        if (!PRMOrderLines.RecId)
            PRMOrderLines.write();
    
        PRMOrderLines.lookupActivePositions(_formControl, PRMOrderLines.AssumedDate); 
       
        //super(_formControl, _filterStr);
    }

    On other form different date field is passed to lookup method, but  everything else is the same.

    I hope now you see the full picture.

    Kind regards,

    Maris

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Pass parameter to display method which is added to lookup method. Is it possible?

    I mean, you can pass the date field from the datasource/table (active record) if you have to display method as parameter

  • Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,421 on at
    RE: Pass parameter to display method which is added to lookup method. Is it possible?

    Hi Maris,

    Based on what do you want to pass this date? Is it a control on the form or a data source field?

  • Maris Sausins Profile Picture
    Maris Sausins 56 on at
    RE: Pass parameter to display method which is added to lookup method. Is it possible?

    Thanks, for your fast reply!

    No I haven't tried that. I actually don't understand what you mean by that? How can I pass parameters from my DS to display method which is displayed in lookup?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Pass parameter to display method which is added to lookup method. Is it possible?

    I guess, we wont be able to pass parameter from lookup field to display method, however you can pass the parameter values from a datasource to display method. did you try that?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans