Skip to main content

Posts

Showing posts with the label Axapta at Runtime

Show field of run time control in MSD axapta

public void showFields(tableId tableId,FormGridControl formGridControl1, FormBuildDataSource formDataSource1) { FormStringControl formStringControl1,formStringControl2; DictTable dictTable; DictTable dictTable1; DictTable dictTable2; fieldId fieldId; int i; int t; int fieldCnt; Query Q1; str ColValue[]; str strQuery; object formRunCaller; ; formRunCaller = element.args().caller(); testId1=formRunCaller.MethodA(); dictTable1 = new DictTable(_TestColumn.TableId); // dictTable2 = new DictTable(_TestRows.TableId); dictTable = new DictTable(tableId); select * from _TestColumn where _TestColumn.QId == _Question.QId && _TestColumn.TestId==testId1 ; if(_TestColumn) { ColValue[1] = _TestColumn.Col1; ColValue[2] = _TestColumn.Col2; ColValue[3] = _TestColumn.Col3; ColValue[4] = _TestColumn.Col4; ColValue[5] = _TestColumn.Col5; ColValue[6] = _TestColumn.Col6; ColValue[7] = _TestColumn.Col7; ColValu

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().calle

Autoform for Microsoft Dynamics Axapta is not advisable

Autoform for dynamics axapta is not advisable If you are seeking for auto form functionality in dynamics axapta then its not advisable because axapta is ERP not language kind of like asp.net or java. Dynamic form and report is feasible to make but it will not work properly. If anyway you able to design and develop run time form then to make report run time is not feasible because lot of design work and formatting may required to client which is only possible in static designed report. Taking everything run time and dynamic is time waste work if you are leading technical team then never advice for run time functionality for form and report. If you want to report run time then showing data in Microsoft excel from axapta is advisable. If you are trying to make dynamic entry from dot net platform and making report in axapta then it will not easily feasible. Crosstab query work well in Microsoft access , sql excel etc but in axapta ERP there is no such facility. So take care d

Code to show Dynamic Reports in MSD axapta

Code to show Dynamic Reports Write following code on init method of report in axapta ReportSection reportSection; DictTable dictTable; DictField dictField; Counter fieldCounter; super(); reportSection = element.design().autoDesignSpecs().addSection(ReportBlockType::Body); reportSection.table(tableNum(custTable)); dictTable = new DictTable(tableNum(custTable)); while (fieldCounter < 10) { fieldCounter++; dictField = new DictField(dictTable.id(), dictTable.fieldCnt2Id(fieldCounter)); reportSection.addControl(dictTable.id(), dictTable.fieldCnt2Id(fieldCounter)); }

show data source information using MSD axapta

show data source information using axapta FormDatasource formDatasource; FormGroupControl formGroupControl; FormStaticTextControl formStaticTextControl; Counter counter; Counter noOfDatasources; ; noOfDatasources = this.form().dataSourceCount(); if (noOfDatasources) { formGroupControl = this.form().design().addControl(FormControlType::Group, "formGroupControl"); formGroupControl.caption("Tables used by form"); formGroupControl.frameType(3); } for (counter=1; counter <= noOfDatasources; counter++) { formStaticTextControl = formGroupControl.addControl(FormControlType::StaticText, "formStaticTextControl" + int2str(counter)); formStaticTextControl.text(tableid2name(this.form().dataSource(counter).table())); }

How to Generate group control at run time in dynamics axapta

To Generate dynamics axapta group control at run time in axapta you can try following code. Group is nothing but its one type of control like frame. In that group you can create other control like stringedit,date,enum and extended data types. In group you can set caption,name ,width,height, left,right etc properties . str groupMarkup = ' '; str fieldsMarkup = ' '; str label; str caption; str name; // only generate a group if in a form and not already in a grid if (_inAxFormControl && !_inGridControl && !_inAxGroupControl) { if (controlNode) { name = controlNode.AOTname(); label = controlNode.AOTgetProperty('Caption'); } if (label != '') { caption = 'Caption="' + this.generateLabelMarkup(label) + '"'; } _markup.appendText(strfmt(groupMarkup, name, this.getNextId(), caption)); _markup.appendText('\r\n'); _markup.appendText(fieldsMarkup); _m

How to Generate dynamics axapta group control using code

This is simple example to Generate dynamics ax group control at runtime using code in x++ lanugage. You can try following code in form. str groupMarkup = ' '; str fieldsMarkup = ' '; if (!_inGridControl && _inAxGroupControl == true) { _inAxGroupControl = false; _markup.appendText(fieldsMarkup); _markup.appendText('\r\n'); _markup.appendText(groupMarkup); _markup.appendText('\r\n'); }

Run the report and send it to a PDF file

EPSendDocument sendDocument; InventTransferJour inventtransferjour ; Filename filename; ; select firstonly inventtransferjour where inventtransferjour.TransferId == 'AB001853' && inventtransferjour.UpdateType == InventTransferUpdateType::Receive; filename = WinAPI::getTempPath() +'MyInvoice.pdf'; sendDocument = new EPSendDocument(inventtransferjour); sendDocument.parmOriginal(true); sendDocument.parmFileName(filename); // Make document will run the report and send it to a PDF file with // the path specified in filename sendDocument.makeDocument();

Add a form list control. in form at runtime using axapta

Add a form list control. in form at runtime using axapta static void createForm2(Args _args) { Args args; Form form; FormRun formRun; FormBuildDesign formBuildDesign; FormBuildDataSource formBuildDataSource; FormBuildListControl formBuildListControl; FormListControl formListControl; FormListItem formListItem; FormListColumn formListColumn1; FormListColumn formListColumn2; FormListColumn formListColumn; DictTable dictTable; int idx4; str string; container conAccountNum; CustTable custTable; int numAccounts; int i; int item; int numItems; ; // Create the form header. form = new Form(); // Add data sources to the form. dictTable = new DictTable(tableNum(custTable)); formBuildDataSource = form.addDataSource(dictTable.name()); formBuildDataSource.table(dictTable.id()); // Create the form design. formBuildDesign = form.addDesign("Design"); formBuildDesign.caption("myForm"); // Add a form list control. formBuildListControl = formB

Print Report to PDF in axapta

Print Report to PDF in axapta static void printToPDF(Args _args) { Args args; ReportRun rr; str reportName = 'ReportName1'; ; args = new Args(reportName); rr = new ReportRun(args,''); rr.setTarget(Printmedium::File); rr.printJobSettings().format(PrintFormat::PDF); rr.printJobSettings().fileName("C:\\Cust_ReportRange.pdf"); rr.printJobSettings().allPages(false); rr.printJobSettings().from(2); rr.printJobSettings().to(4); // Disables forms that enable users to modify // the report query and print settings. rr.query().interactive(false); rr.report().interactive(false); rr.run(); }

Create report runtime in axapta through code

This is code sample to Create report runtime in axapta through code static void MakeReportInJob(Args _args) { #AOT str reportName = 'aatestReport'; tableid custTableId = tablenum(CustTable); TreeNode reportNode = TreeNode::findNode(#ReportsPath); Report areport; ReportDesign design; ReportAutoDesignSpecs specs; ReportSection section; ReportRun run; ; // Delete the report if it already exists areport = reportNode.AOTfindChild(reportName); if (areport) areport.AOTdelete(); // Build the report areport = reportNode.AOTadd(reportName); areport.query().addDataSource(custTableId); design = areport.addDesign('Design'); specs = design.autoDesignSpecs(); section = specs.addSection(ReportBlockType::Body, custTableId); section.addControl(custTableId, fieldnum(CustTable, AccountNum)); section.addControl(custTableId, fieldnum(CustTable, Name)); // Now the report will not prompt for user input areport.inter

select All Records Dynamically in axapta

This is sample code to select All Records Dynamically in axapta static void selectAllRecordsRuntimeArgs _args) { firstTable firstTable; DictField dictField; DictTable dictTable; int field; int fieldId; int records; str header, line; ; // Create a new object of type DictTable based on the firstTable dictTable = new DictTable(tablenum(firstTable)); // Loop through the fields on the table. // For each field, store the field-label in the header variable. for (field=1; field <= dictTable.fieldCnt(); field++) { fieldId = dictTable.fieldCnt2Id(field); dictField = new DictField(tablenum(firstTable), fieldId); header += strfmt("%1, ", dictField.label()); } info(strupr(header)); // strupr changes the string to UPPERCASE // Loop through all the records in the firstTable while select firstTable { line = ""; // For each record in the firstTable, loop through all the //fields // and store the value of the field

Create and delete folder using axapta x++ code

This is sample of code to Create and delete folder using axapta in x++ code. This code you can check in job or any button click . First you need to test this code before applying to production server. public void CreateFolder() { boolean FlagFolderExist,FlagFileExist; FlagFolderExist = WINAPI::folderExists("C:\\roll\\"+ cate1); if(FlagFolderExist == false) { WINAPI::createDirectoryPath("C:\\roll\\"+rollcate1); } FlagFileExist = WINAPI::fileExists("C:\\roll\\" + rollcate1 + "\\" + Tmpemplname); if(FlagFileExist == true) { WINAPI::deleteFile("C:\\roll\\" + rollcate1 + "\\" + Tmpemplname); } }

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

Runtime form controls using Axapta and save data

This is sample code for Runtime form controls using MSD Axapta and save data to table public void GenerateControl() { int i; int a; int d; str lable; DictTable dictTable; TableId tableID; ; 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 order by RecId { a = 1; while select * from answer where answer.GroupId == _Question.GroupId { if(_Question.ControlId == QuestionControlInputType::CheckBox) { formCheckBoxControl = formGroupCont