web
You’re offline. This is a read only version of the page.
close
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 21

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

I have the same question (0)
  • Community Member Profile Picture
    on at

    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?

  • Maris Sausins Profile Picture
    21 on at

    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?

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Maris,

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

  • Community Member Profile Picture
    on at

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

  • Maris Sausins Profile Picture
    21 on at

    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

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    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
    21 on at

    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

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans