Lookup the field names of datasource

Hi All,

  1. I need to lookup the form labels. I ve given “formname” edt, but it s displaying same form name twice.

  2. I need to create a lookup consisting field names for the chosen form name.

Regards,

S.Kuppusamy

Hi kuppusamy

following code will help you (for point 2)

public void lookup()
{
SysTableLookup sysTableLookup;
Treenode formnaode= treenode::findNode(@‘\forms\Form64\data sources’);// Form64 must be your form name
DictTable dicttab;
sysDictField field;
Treenode datasource=formnaode.AOTfirstChild();
str nameofdatsource;
int i;
;
if(datasource)
{
nameofdatsource=datasource.AOTgetProperty(‘Table’);

sysTableLookup=sysTableLookup::newParameters(tableName2Id(nameofdatsource),this);
dicttab=new DictTable(tableName2Id(nameofdatsource));
for (i=1;i<=dicttab.fieldCnt();i++)
{
field=new sysDictField(dicttab.id(),dicttab.fieldCnt2id(i));

if(!field.isSystem())
{
sysTableLookup.addLookupfield(field.id());
}

}

}

sysTableLookup.performFormLookup();

}

regards

P.RAM

Hi Ram,

Thank you for your code. I did the same using syspicklist class. It works well

Thanks

S.Kuppusamy

Hi Kuppusamy,

Would you please post the code

Regards,

P.Ram

Hi ram,

What I did was, I inserted the datasources name in a table named “DisplayTableName”, based on the form selection I made. I ll fetch the data if It s available already in the table or else I ll insert it and pass the arguments and get lookup.

void lookup()

{

str _formNameStr;

TreeNode tn;

Args args;

TableName tableNam;

SysTableLookup sysTableLookup;

Query query = new Query(); QueryBuildDataSource qbds;

SysQueryform sysQueryform; ; _formNameStr = AGRUnitMapping.

FormName; tn = infolog.findNode(‘FORMS’).AOTfindChild(_formNameStr);

if(tn) tn = tn.AOTfindChild(“Data Sources”).AOTfirstChild();

while(tn)

{

tableNam = tn.AOTgetProperty(“Table”);

tableId = tablename2id(tableNam);

displayTableName = DisplayTableName::find(_formNameStr,tableNam);

if(!displayTableName)

{

displayTableName.FormName = _formNameStr;

displayTableName.TableName = tableNam;

displayTableName.insert();

}

tn = tn.AOTnextSibling();

}

sysTableLookup=SysTableLookup::newParameters(tablenum(DisplayTableName), this);

sysTableLookup.addLookupfield(fieldnum(DisplayTableName, TableName));

qbds = query.addDataSource(tablenum(DisplayTableName));

qbds.addRange(fieldnum(DisplayTableName,FormName)).value(AGRUnitMapping.FormName);

if(sysTableLookup)

{

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();

}

}

The above code is to get the table name from Form.

the following code is to get fields from table name,

The fieldid is edit method written in table level and added it in form design

public void lookup()
{
FieldId fieldId;
Map map;
TableName table;
Args args;
FormRun formRun;
;
AGRUnitMapping.Table_Id = tablename2id(AGRUnitMapping.TableName);
fieldId = pickField(AGRUnitMapping.Table_Id);

if (fieldId)
{
AGRUnitMapping.FieldId = fieldId;
AGRUnitMapping.FieldName = Fieldid2Name(AGRUnitMapping.Table_Id,AGRUnitMapping.FieldId);
AGRUnitMapping_ds.refresh();
}
}

Regards,

S.Kuppusamy

Hi Kuppusamy,

Thanks for your reply.