Unbalanced X++ TTSBEGIN/TTSCOMMIT
Run this job For get rid of this error
static void _ResetTTS(Args _args)
{
while (appl.ttsLevel() > 0)
{
info( strfmt("Level %1 aborted" ,appl.ttsLevel()));
ttsAbort;
}
}
This blog is contains coding reference related to Microsoft AX 2012 and D365 finance and operations and Power platform
static void _ResetTTS(Args _args)
{
while (appl.ttsLevel() > 0)
{
info( strfmt("Level %1 aborted" ,appl.ttsLevel()));
ttsAbort;
}
}
Query query;
QueryRun queryRun;
QueryBuildDataSource qbds1;
QueryBuildRange qbr1, qbr2,qbr3,qbr4;
query = new Query();
qbds1 = query.addDataSource(tableNum(Table_Name));
if(Condition)
{
qbr1 = qbds1.addRange(fieldNum(Table_Name, Fieldname1));
qbr1.value("Value");
}
if(Condition)
{
qbr2 = qbds1.addRange(fieldNum(Table_Name, Fieldname2));
qbr2.value("Value");
}
if(Condition)
{
qbr3 = qbds1.addRange(fieldNum(Table_Name, Fieldname2 ));
qbr3.value("Value");
}
if(Condition)
{
qbr4 = qbds1.addRange(fieldNum(Table_Name, Fieldname3));
qbr4.value("Value");
}
queryRun = new QueryRun(query);
//This is for lookup with InnerJoin ////Write in Form Level Design>Field>Lookup public void lookup() { // create the query for the lookup Query query = new Query(); QueryBuildDataSource cpj; QueryBuildDataSource bol; QueryBuildRange qbr1; // Intantiantes a SysTableLookup object telling it which control activated the lookup, and // what table should be displayed inside the lookup form.(root table) //"Failed to execute query because no root data source on the form matches the root datasource on the query" //This error can occur when the wrong TableId is passed in SysTableLookup::newParameters(). //Make sure you use the table you want to do the lookup in (not the table you're doing for). SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(LTCustomerDetails),this); cpj = query.addDataSource(tablenum(LTCustomerDetails)); qbr1 = cpj.addRange(fieldnum(LTCustomerDetails,LTCustomerID)); qbr1.value(queryvalue('3')); //Join Table bol = cpj.addDataSource(tablenum(LTPurchaseDetails)); bol.relations(false); bol.joinMode(joinmode::InnerJoin); bol.addLink(fieldnum(LTCustomerDetails,LTCustomerID),fieldnum(LTPurchaseDetails,LTCustomerID)); //Add the query to the lookup form sysTableLookup.parmQuery(query); // Add fields that will be shown in the lookup as columns // Specify the fields to show in the form. sysTableLookup.addLookupfield(fieldNum(LTCustomerDetails,LTCustomerID)); sysTableLookup.addLookupfield(fieldNum(LTPurchaseDetails,LTCustomerName)); // Perform the lookup sysTableLookup.performFormLookup(); } example public void lookup() //on form level { Query query = new Query(); QueryBuildDataSource queryBuildDataSource; QueryBuildDataSource queryBuildDataSource2; QueryBuildRange queryBuildRange; SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventTable), this); sysTableLookup.addLookupField(fieldNum(InventTable, ItemId)); sysTableLookup.addLookupField(fieldnum(InventTable,NameAlias)); queryBuildDataSource = query.addDataSource(tableNum(InventTable)); queryBuildDataSource2 = queryBuildDataSource.addDataSource(tablenum(EcoResProduct)); queryBuildDataSource2.relations(false); queryBuildDataSource2.joinMode(joinmode::InnerJoin); queryBuildDataSource2.addLink(fieldnum(EcoResProduct,RecId),fieldnum(InventTable,Product)); queryBuildRange = queryBuildDataSource2.addRange(fieldNum(EcoResProduct,LTPurchaseOrderType)); queryBuildRange.value(enum2str(PurchTable.LTPurchaseOrderTypes)); sysTableLookup.parmQuery(query); sysTableLookup.performFormLookup(); }
switch (value)
{
case 1:
case 2:
case 3:
//do some stuff
break;
case 4:
case 5:
case 6:
//do some different stuff
break;
default:
//default stuff
break;
}
More info
icon by Icons8