Skip to main content

Save value to table from run time control in MSD Axapta

Save value to table from run time control in Axapta

 void SaveAll()  
 {  
 int i;  
 int a;  
 int c;  
 boolean flg=true,flg1=true;  
 FormStringControl FormStr1;  
 FormStringControl formStringControl1;  
 FormGroupControl formGroupControl1;  
 str oldqid,tid,oldtxt;  
 FormTabControl formTabControl1;  
 FormTabPageControl formTabPageControl1;  
 FormBuildTabControl formBuildTabControl;  
 FormBuildGroupControl formBuildGroupControl;  
 FormBuildTabPageControl formBuildTabPageControl;  
 FormBuildStringControl formBuildStringControl;  
 _TestResult _testResult1;  
 str s,fcname;  
 formControl fc,fc1;  
 boolean f=false;  
 FormStringControl control = element.controlCallingMethod();  
 Integer yy,x;  
 int cnt=0,cnt1=0;  
 str id,AnsTxtGrid;  
 int t;  
 int rcnt,tmpcnt,rowid1;  
 str 10 AnsTxt;  
 str lable;  
 DictTable dictTable;  
 TableId tableID;  
 object formRunCaller;  
 TestId testId2;  
 ;  
 idrow=1;  
 rowid1=1;  
 //tmpcnt=16;  
 formRunCaller = element.args().caller();  
 testId2=formRunCaller.MethodA();  
 i = 1;  
 x=12000;  
 for(yy = x;yy <20000;yy++)  
  { fc = element.Control(yy);  
 if (fc)  
  {  
 while select * from _Question where (_Question.TestID==testid2) //order by RecId  
 {  
 while select * from tmpControlId where tmpControlId.ControlID==int2str(yy)  
  {  
 flg=false;  
  }  
 //select * from _TestResult; _TestResult.QId = _Question.QId;  
  _TestResult.Text= ""; a = 1;  
  while select * from answer where answer.GroupId == _Question.GroupId  
  {  
  if(_Question.ControlId == QuestionControlInputType::CheckBox)  
  {  
 }  
  if(_Question.ControlId == QuestionControlInputType::RadioButton)  
 {  
 }  
 a = a+1;  
  }  
  if(_Question.ControlId == QuestionControlInputType::Text)  
 {  
 // formGroupControl if(fc.name()=="QuestionStr")  
 {  
 // cnt=cnt+1;  
  // cnt1=i-12;  
 if (flg1==true)  
 {  
 fc = element.Control(yy);  
 //formBuildStringControl = formBuildTabPageControl.controlNum(i);  
 // lable =formBuildStringControl.name();  
  _TestResult.GroupId ="0";  
  _TestResult.RowId = "0";  
  // if(cnt==cnt1)  
 ///ss  
  while select _testResult1 where _testResult1.QId ==_Question.QId && _testResult1.TestId==testid2 {  
  flg=false;  
 }  
 if (flg==false)  
  {  
 flg=true;  
  }  
  else if(flg==true)  
  {  
 // _testResult.ItemID=inventTrans1.ItemId;  
 // _testResult.ItemName=InventTable::find(inventTrans1.ItemId).ItemName;  
 AnsTxt=fc.valueStr();  
  _TestResult1.Text=AnsTxt;  
 _TestResult1.QId = _Question.QId; _TestResult1.TestId=testId2;  
 //"1";  
 _TestResult1.GroupId ="0";  
 _TestResult1.RowId = "0";  
  _testResult1.insert();  
 tmpControlId.ControlID=int2str(yy);  
  tmpControlId.Qid=_question.QId;  
  tmpControlId.insert(); } flg=true;  
 } }  
  else  
  { flg1=true;  
 } ///ss  
 // _testResult.insert();  
 }  
 else if (_Question.ControlId == QuestionControlInputType::Grid)  
 {  
 // rcnt=rcnt+1  
 info(_testGridResult1.Row); fcname=fc.name(); if(substr(fc.name(),12,16)=="Col1")  
  {  
  idrow=rowid1;  
 _TestGridResult1.Column="1";  
  fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
  _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
  rowid1=idrow+1;  
 }  
  else if(substr(fc.name(),12,16)=="Col2")  
 { fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
  _TestGridResult1.Column="2";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
 }  
  else if(substr(fc.name(),12,16)=="Col3")  
  {  
  fc = element.Control(yy);  
  _TestGridResult1.Column="3";  
  AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
 }  
 else if(substr(fc.name(),12,16)=="Col4")  
  {  
 fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="4";  
 _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
  }  
 else if(substr(fc.name(),12,16)=="Col5")  
 {  
 fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="5";  
  _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
  }  
 else if(substr(fc.name(),12,16)=="Col6")  
  {  
 fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="6";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
  }  
  else if(substr(fc.name(),12,16)=="Col7")  
 {  
  fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="7";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
  }  
 else if(substr(fc.name(),12,16)=="Col8")  
  {  
 fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
  _TestGridResult1.Column="8";  
  _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
  }  
 else if(substr(fc.name(),12,16)=="Col9")  
  { fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
  _TestGridResult1.Column="9";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
 }  
 else if(substr(fc.name(),12,16)=="Col10")  
  {  
 fc = element.Control(yy);  
  AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="10";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
 } //ss else if(substr(fc.name(),12,16)=="Col11")  
  { fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="11";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
 }  
 else if(substr(fc.name(),12,16)=="Col12")  
 {  
 fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="12";  
 _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
 }  
  else if(substr(fc.name(),12,16)=="Col13")  
 { fc = element.Control(yy);  
  AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="13";  
 _TestGridResult1.Text=AnsTxtGrid;  
 _TestGridResult1.insert();  
 } else if(substr(fc.name(),12,16)=="Col14")  
 {  
 fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="14";  
  _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
 }  
 else if(substr(fc.name(),12,16)=="Col15")  
 { fc = element.Control(yy);  
  AnsTxtGrid=fc.valueStr();  
  _TestGridResult1.Column="15";  
  _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert();  
  }  
 else if(substr(fc.name(),12,16)=="Col16")  
 { fc = element.Control(yy);  
 AnsTxtGrid=fc.valueStr();  
 _TestGridResult1.Column="16";  
  _TestGridResult1.Text=AnsTxtGrid;  
  _TestGridResult1.insert(); }  
 //rowid=rowid1; //ss i = i+1; } i = i+1;  
 }  
  }  
 }  
 info ("Record Saved Success");  
 }  

Popular posts from this blog

Code to get customer Primary Address in Ax 2012

Below Code to get customer Primary Address in Ax 2012. CustTable custTable_P; DirPartyTable dirPartyTable_P; DirPartyLocation dirPartyLocation_P; DirPartyLocationRole dirPartyLocationRole_P; LogisticsLocation logisticsLocation_P; LogisticsLocationRole logisticsLocationRole_P; LogisticsPostalAddress logisticsPostalAddress_P; LogisticsPostalAddress primaryAddress_P; while select custTable_P where custTable_P.AccountNum =='ED_01029' join dirPartyTable_P where dirPartyTable_P.RecId == custTable_P.Party join dirPartyLocation_P where dirPartyLocation_P.Party == custTable_P.Party && dirPartyLocation_P.IsPrimary==NoYes::Yes join dirPartyLocationRole_P where dirPartyLocationRole_P.PartyLocation == dirPartyLocation_P.RecId join logisticsLocationRole_P where logisticsLocationRole_P.RecId == dirPartyLocationRole...

Table lists which can have large number of records in Ax 2012

If you are facing database or application performance issue then you can check these tables that may have large number of records. ECORESPRODUCTVARIANTDIMENSIONVALUE INVENTBATCH ECORESPRODUCTMASTERDIMENSIONVALUE ECORESPRODUCTMASTERDIMENSIONVALUE ECORESPRODUCT ECORESPRODUCTTRANSLATION ECORESPRODUCT ECORESPRODUCTVARIANTDIMENSIONVALUE INVENTDIMCOMBINATION ECORESRELEASESESSIONPRODUCT ECORESRELEASEPRODUCTLEGALENTITY INVENTSUMLOGTTS INVENTCOSTLISTPARM GENERALJOURNALACCOUNTENTRY GENERALJOURNALACCOUNTENTRYZAKAT_SA SMMTRANSLOG LEDGERENTRYJOURNALIZING DIMENSIONFOCUSBALANCE MARKUPTRANS INVENTTRANSPOSTING INVENTREPORTDIMHISTORY SALESPARMLINE SOURCEDOCUMENTLINE INVENTTRANS TRANSACTIONLOG INVENTTRANSORIGIN INVENTSETTLEMENT SALESPARMSUBTABLE SALESPARMTABLE SOURCEDOCUMENTHEADER SALESPARMUPDATE SQLSYNCINFO GENERALJOURNALENTRY SUBLEDGERVOUCHERGENERALJOURNALENTRY CUSTSETTLEMENT SMMACTIVITYPARENTLINKTABLE INVENTSUMDATETRANS LEDGERTRANSSTATEMENTTMP DIMENSIONFOCUSLE...

Code to get Invoice settlement data for customer in ax 2012

This is simple Code to get Invoice settlement amount data for customer payment in ax 2012. This data is after posting of data. select sum(SettleAmountCur) from custSettlement where custSettlement.TransRecId == custtrans.RecId If you want get settlement amount before posting than you can refer spectrans table.The table SpecTrans contains all the transactions marked for settlement for payment journal. while select spectrans join custtransopen join custtrans where spectrans.SpecCompany == ledgerjournaltrans.DataAreaId && spectrans.SpecTableId == ledgerjournaltrans.TableId && spectrans.SpecRecId == ledgerjournaltrans.RecId && spectrans.RefCompany == custtranssopen.DataAreaId && spectrans.RefTableId == custtranssopen.TableId && spectrans.RefRecId == custtranssopen.RecId && custtransopen.RefRecId == custtrans.RecId && custtransopen.AccountNum == custtrans.AccountNum { info...