Thursday, March 16, 2023

Open table browser using x++

 Open table browser using x++.


If we want to open the table browser we need to open visual studio, right-click on the table and select the option like the below screenshot.




My functional required one form and in that he expected one field. That field lookup contains all table lists.


So I have created one form and added a field and button.



Lookup method:

    public void lookup()
    {
	Query                   query;
	QueryBuildDataSource    qbds;
	SysTableLookup          lookup;
	
	super();

	query 	= new Query();
	qbds 	= query.addDataSource(tableNum(SqlDictionary));
	lookup 	= SysTableLookup::newParameters(tableNum(SqlDictionary), this);
	
	qbds.clearRanges();
	qbds.addRange(fieldNum(SqlDictionary, fieldId)).value('0');
	
	lookup.addLookupfield(fieldNum(SqlDictionary, Name));
	lookup.addLookupfield(fieldNum(SqlDictionary, SqlName));
	lookup.parmQuery(query);
	lookup.performFormLookup();
    }


Clicked method:

    public void clicked()
    {           
	SysTableBrowser sysTableBrowser;            

	str tName;

	super();
	
	tName = TableName.valueStr();
	
	if (!tName)
	{
	    throw error(strfmt("@ApplicationFoundation:SysTableBrowser_MissingTableName"));
	}

	sysTableBrowser = new SysTableBrowser();
	sysTableBrowser.parmTableName(tName);
	sysTableBrowser.run(tablename2id(tName));
    }

Keep Daxing!!









No comments:

Post a Comment