Hello!
Is it possible to pass paramater to display method which is added to lookup!
And my display method:
I need to pass specific date to this method, to dislpay correct values? Is it even possible this way?
Kind regards,
Maris
Hello!
Is it possible to pass paramater to display method which is added to lookup!
And my display method:
I need to pass specific date to this method, to dislpay correct values? Is it even possible this way?
Kind regards,
Maris
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
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.
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) :
With 3 DS, On PrmOrderlines_DS field control I have overidden lookup method:
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
I mean, you can pass the date field from the datasource/table (active record) if you have to display method as parameter
Hi Maris,
Based on what do you want to pass this date? Is it a control on the form or a data source field?
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?
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?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,269 Super User 2024 Season 2
Martin Dráb 230,198 Most Valuable Professional
nmaenpaa 101,156