问题
I want to get the RecId selected from lookup method?
In lookup method in StringEditLookup_ZipCode
public void lookup()
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(LogisticsAddressZipCode), this);
sysTableLookup.addLookupField(fieldNum(LogisticsAddressZipCode, ZipCode));
sysTableLookup.addLookupField(fieldNum(LogisticsAddressZipCode, City));
sysTableLookup.addSelectionField(fieldNum(LogisticsAddressZipCode, RecId));
queryBuildDataSource = query.addDataSource(tableNum(LogisticsAddressZipCode));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
//super();
}
In modified
method I would want to get ad read and use the RecId taken.
I want to populate the StringEditLookup_ZipCode with the ZipCode value.
It's possible to take a RecID ? The LogisticsAddressZipCode Table is's not indexed by ZipCode for this I need to take the RecID.
There is a way to save in a global variable or somehow recid selected in the lookup method or another point?
Thanks all,
enjoy!
回答1:
As far as I know this cannot be done with the SysTableLookup
Framework. Basically you want your lookup to return two values, the ZipCode
and the RecId
. But the framework can only return one value.
So instead of the framework you will need to implement your own lookup by creating a new lookup form. From this form you can then retrieve the selected record in the lookup
method. Here is some code to give you an idea how the lookup
method could look like:
public void lookup()
{
FormRun lookupFormRun;
Args args;
LogisticsAddressZipCode myLookupZipCode;
args = new Args();
args.name(formStr(MyNewLookupForm));
lookupFormRun = classFactory.formRunClass(args);
lookupFormRun.init();
this.performFormLookup(lookupFormRun);
lookupFormRun.wait();
if (lookupFormRun.closedOk())
{
myLookupZipCode= formRun.docCursor();
}
}
From there you can save the RecId
of myLookupZipCode
to a class variable and then later use it in the modified
method.
Also take a look at Lookup form returning more than one value for additional Information.
回答2:
What you have there is exactly what I would've tried. What happens when you choose a value from the lookup? If that isn't working, I'd try adding RecId as one of the lookupFields. It's probably something where it isn't selecting the field so it's always blank. That's the first thing I would try.
来源:https://stackoverflow.com/questions/33369015/how-to-get-recid-selected-from-lookup-method