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

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...

Cancel Deliver Remainder through X++ (Sales Order ) DAX

 To Cancel Deliver Remainder through X++ you can use below code sample. Thanks. static void _CancelDeliverRemainder_Sales(Args _args) {     SalesLine SalesLine = SalesLine::find('SO0013', true);     ;           if (SalesLine)     {         // Set remaining inventory Qty to zero         SalesLine.RemainInventPhysical  = 0;           // Set remaining physical Qty to zero         SalesLine.RemainSalesPhysical   = 0;                                   // We have to cancel the SalesLine                  SalesLine.PurchStatus           = PurchStatus::Canceled;                    SalesLine.update();         ...

Add Miscellaneous Charges to a Purchase Order in MSD Axapta

Add Miscellaneous Charges to a Purchase Order To add miscellaneous charges to a purchase order, follow these steps: 1. Click Accounts payable > Purchase Order Details. 2. Select a purchase order and then click Posting > Invoice. 3. Enter or select an invoice. 4. Select which miscellaneous charges transactions to add, change, or delete: a. To add, change, or delete miscellaneous charges transactions for the invoice header, click Setup > Misc. charges on the Overview tab. b. To add, change, or delete miscellaneous charges transactions for an invoice line, click the Lines tab, and then click Misc. charges. c. To add, change, or delete miscellaneous charges for the invoice header for a summary invoice that is selected on the Overview tab, click the Purchases tab, and then click Setup > Misc. charges. 5. In the Misc. charges transactions form, enter the miscellaneous charge from the invoice that you received from your vendor. 6. If necessary, you can click ...