0

Has anyone ever created a dynamic dialog formstringcontrol with a lookup that contains two columns? Something like VALUE - DETAILS where Value is returned to the field upon selection.

For me, this generally works, except the second (details) column always comes back as Unretrieved.

Query                   query = new Query();
QueryBuildDataSource    datasource;
QueryFilter             qFilter;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(MyTable), _control);
sysTableLookup.addLookupField(fieldNum(MyTable, Field1));
sysTableLookup.addLookupField(fieldNum(MyTable, Field2));
datasource = query.addDataSource(tableNum(MyTable));
datasource.addGroupByField(fieldNum(MyTable, Field1));
datasource.addOrderByField(fieldNum(MyTable, Field1));
    qFilter = query.addQueryFilter(datasource,'Field3');
    qFilter.value('FilterValue');
}

sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();

Second field unretrieved

Brad
  • 1,357
  • 5
  • 33
  • 65
  • Not sure I understand the question correctly, but https://ztirom.at/2015/12/ax2012-dialog-custom-lookup/ seems to do what you are asking. – FH-Inway Jun 30 '20 at 09:12
  • Exactly what I was looking for.. and surprisingly easy. Thanks! – Brad Jun 30 '20 at 10:34
  • To help others find this more easily, you could write an answer based on that link and your own solution. – FH-Inway Jun 30 '20 at 15:20
  • Will do, once it works. : ) Ran into a bit of a snag. Will update the primary question so we have a complete thread. – Brad Jun 30 '20 at 15:37
  • Just a note, I see two duplicate `datasource.addOrderByField(fieldNum(MyTable, Field1));` lines. Sometimes `Unretrieved` is resolved by an AOS restart. The reasons for it are longer than the comment will allow. – Alex Kwitny Jun 30 '20 at 15:53
  • I think the "duplicate" was a group by statement, not a second order by. Restarting didn't fix, but you inadvertently let me to the answer. Will post on the thread separately. Thanks! – Brad Jun 30 '20 at 16:07

1 Answers1

2

This ended up being very simple.

The second field was not included in the group by values, but was a string, and thus could not be aggregated. Therefore it was unretrieved.

In this case, I was just able to remove the Group By attribute, but I suspect grouping by both would have fixed it as well.

Brad
  • 1,357
  • 5
  • 33
  • 65