Skip to main content

add run time control in axapta

This is a sample code to add run time control in axapta form. This is not 100% accurate code but this can help you to create run time control.

There is no guarantee that  run time control will work perfectly in Ax I tried it but did not get much success on this but what success I get I shared here.

 public void init()  
 {  
 int i;  
 int a;  
 int d;  
 int j=0;  
 str lable;  
 DictTable dictTable;  
 TableId tableID;  
 //TestId testId1;  
 FormStringControl fStringTestID;  
 str GetParm;  
 str ParmCaller;  
 /////  
 FormBParams formBParams;  
 Array items;  
 object formRunCaller;  
 //FormRun formRun;  
 //Args args;  
 ;  
 // if( element.args() )  
 // {  
 // get string parameter  
 // testId1= this.TestID() ;  
 formRunCaller = element.args().caller();  
 if(formRunCaller)  
 {  
 testId1=formRunCaller.MethodA();  
 }  
 // }  
 //ssss  
 /*if(element.args())  
 {  
 testId1=element.args().parm();  
 }  
 if(element.args().caller())  
 {//element.args().record().update();  
 _Question1 = element.args().record();  
 // _Question1.update();  
 testId1=_Question1.TestID;  
 }*/  
 i = 1;  
 d=1;  
 a=0;  
 lable = "";  
 formTabControl = this.form().addControl(FormControlType::Tab,"MainTab");  
 formTabControl.heightMode(1);  
 formTabControl.widthMode(1);  
 formTabPageControl = formTabControl.addControl(FormControlType::TabPage,"MainTabPage");  
 formTabPageControl.caption("Test");  
 this.controlMethodOverload(true);  
 formGroupControl = formTabPageControl.addControl(FormControlType::Group, "MyGroup");  
 formGroupControl.caption("Test");  
 while select * from _Question where (_Question.TestID==testId1) //order by RecId  
 {  
 a = 1;  
 while select * from answer where answer.GroupId == _Question.GroupId  
 {  
 if(_Question.ControlId == QuestionControlInputType::CheckBox)  
 {  
 formCheckBoxControl = formGroupControl.addControl(FormControlType::CheckBox, num2str(i,2,0,0,0) + num2str(a,2,0,0,0) + "Question" );  
 formCheckBoxControl.label(answer.Text);  
 }  
 if(_Question.ControlId == QuestionControlInputType::RadioButton)  
 {  
 formRadioControl = formGroupControl.addControl(FormControlType::RadioButton, num2str(i,2,0,0,0) + num2str(a,2,0,0,0) + "Question" );  
 formRadioControl.caption(answer.Text);  
 }  
 a = a+1;  
 }  
 if(_Question.ControlId == QuestionControlInputType::Text)  
 {  
 formStringControl = formGroupControl.addControl(FormControlType::String, "QuestionStr" ); //num2str(i,2,0,0,0) +  
 formStringControl.label( num2str(i,2,0,0,0) + ". "+ _Question.QText + ":");  
 }  
 else if (_Question.ControlId == QuestionControlInputType::Grid)  
 {  
 formStaticTextControl = formGroupControl.addControl(FormControlType::StaticText, "Question" );//num2str(i,2,0,0,0) +  
 formStaticTextControl.text(num2str(i,2,0,0,0) + ". "+ _Question.QText + ":");  
 formDataSource = new FormBuildDataSource();  
 // this.form().addDataSource("_dataGridTbl");  
 formDataSource = this.form().dataSource(d);  
 tableID =_dataGridTbl.TableId;  
 dictTable = new DictTable(this.form().dataSource(d).table());  
 formDataSource.name( num2str(i,2,0,0,0) + "QuestionDb");  
 formDataSource.name(this.form().dataSource(d).name());  
 formDataSource.name(dictTable.name());  
 // formDataSource.table(this.form().dataSource(d).table());  
 formDataSource.autoQuery(true);  
 formGridControl = formGroupControl.addControl(FormControlType::GRID, "QuestionGri" );//num2str(i,2,0,0,0) +  
 formGridControl.dataSource(dictTable.name());//();  
 formGridControl.widthMode(1);  
 formGridControl.heightMode(1);  
 this.showFields(tableNum(_dataGridTbl), formGridControl, formDataSource);  
 d =d+1;  
 }  
 i = i+1;  
 }  
 formButtonControl = this.form().addControl(FormControlType::Button, "CmdSave");  
 formButtonControl.text("Save");  
 form1 = this.form();  
 //new  
 /* while select _TestRows where _TestRows.TestId==testId1  
 {  
 j=j+1;  
 if (j==1)  
 {  
 while select _TestRows1 where _TestRows1.TestId==testId1 && _TestRows1.ColumnNo=="1"  
 {  
 tmp_DataGridTabl.TestID=testId1;  
 tmp_DataGridTabl.QId="15";  
 tmp_DataGridTabl.Col1=_TestRows1.RowDescription;  
 tmp_DataGridTabl.insert();  
 }  
 }  
 }  
 select forupdate tmp_DataGridTabl;*/  
 // formGridControl.dataSource(tmp_DataGridTabl);  
 //new  
 // formButtonControl = this.form().addControl(FormControlType::Button, "CmdShow");  
 // formButtonControl.text("Show");  
 super();  
 }  

Popular posts from this blog

strScan and Find a first occurrence of a string in a string using x++

strScan (Find a first occurrence of a string in a string) info("int strScan(str _text1,str _text2,int _position,int _number)"); info("Searches a text string for the occurrence of another string."); info("_text1 - The text string to search."); info("_text2 - The string to find."); info("_position - The position at which the search should start."); info("_number - The number of characters that should be searched."); info(int2str(strScan("ABCDEFGHIJ","DE",1,10)));

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

Get record from table on the basis of field id in Microsoft dynamics axapta x++

How to Get record from table on the basis of field id in dynamics axapta x++. just try following code in job to understand better way. emplTable emplTable; FieldId fieldId; ; fieldId = fieldNum(emplTable, Emplid); select emplTable; info(emplTable.(fieldId)); select emplTable where emplTable.(fieldId) == '1101'; info(emplTable.Name);