Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

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

(0) ShareShare
ReportReport
Posted on by 11

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
    11 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
    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
    11 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
    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
    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
    11 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
    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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,202 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans