Skip to main content

Posts

Get ODBC Type using axapta code

Get ODBC Type using axapta code ODBCConnection connection; SqlSystem sqlSystem = new SqlSystem(); LoginProperty loginProperty = sqlSystem.createLoginProperty(); Statement statement; ResultSet resultSet; SqlStatementExecutePermission sqlStatementExecutePermission; str sqlStatement; loginProperty = sqlSystem.createLoginProperty(); loginproperty.setOther(strfmt('dsn=abc;uid=xyz;pwd=dds')); connection = new ODBCConnection(loginProperty); statement = connection.createStatement(); sqlStatement = "select * from test "; sqlStatementExecutePermission = new SqlStatementExecutePermission(sqlStatement); qlStatementExecutePermission.assert(); resultSet = statement.executeQuery(sqlStatement); while(resultset.next()) { info(strfmt("%1 %2", resultset.getString(1), resultset.getString(2))); }

Data Backup in Microsoft Dynamics AX

1) Axapta Table Backup - Using “Definition Group” 2) SQL Backup (Axapta Table backup and Olap database backup) 3) Application Back-up ( Customization Back-up) 4) OLAP Visual Studio project backup 1. Axapta Table Backup - Using “Definition Group”: Go to Administration > Periodic > Data Export / Import > Definition Group > Create new Definition group “ Table Back up” Identify the name of a definition group. Click on “Include Table Groups” tab. Select all the check boxes including the transactions also. Click OK. A definition group will get created in the form Data exporting will start and two files with extension *.dat and *.def will be saved in selected location.

Create a new number sequence

Creating a new number sequence is achieved by creating a new reference for the sequence. Follow these steps to create a new number sequence: 1. Create a new Extended Data Type (EDT). Often this EDT extends num. This is not mandatory, but it is a best practice. 2. Decide which module’s parameters this number sequence reference should be included in, and find the corresponding NumberSeqReference sub class. 3. The loadModule() method shows a number of blocks of code, which creates records in the table NumberSequenceReference. 4. Copy one of these blocks and change the following fields: a. DataTypeID is the type Id of the new data type. b. referenceLabel is the description shown in the left column of the Number sequence tab on the parameters form. c. referenceHelp is the longer description of the reference shown in the top part of the Number sequence tab of the parameters form. d. sortfield defines the sequence that the references are displayed on the Num

Microsoft Dynamics AX certification

Microsoft Certified IT Professional: Applications for Microsoft Dynamics AX 2009 Note You must pass one required exam and three elective exams to obtain a certification. Exam title Exam number Required: Financials in Microsoft Dynamics AX 2009 Exam MB6-818 Elective: Trade and Logistics in Microsoft Dynamics AX 2009 Exam MB6-817 Elective: Development Introduction in Microsoft Dynamics AX 2009 Exam MB6-819 Elective: Production in Microsoft Dynamics AX 2009 Exam MB6-822 Elective: Project Series in Microsoft Dynamics AX 2009 Exam MB6-823 Elective: Human Resource Management in Microsoft Dynamics AX 2009 Exam MB6-824 Elective: Product Builder in Microsoft Dynamics AX 2009 Exam MB6-826 Elective: Payroll in Microsoft Dynamics AX 2009 Exam MB6-827 Microsoft Certified IT Professional: Developer for Microsoft Dynamics AX 2009 Note You must pass two required exams and two elective exams to obtain a certification. Exam title Exam number Req

Microsoft Dynamics AX development certification

Microsoft Dynamics AX development certification •Development – Introduction •Development – Enterprise Portal •Development – MorphX Solution •Financials •Human Resources Management •Installation and Configuration •Product Builder •Production •Project Series •Questionnaire •Sales and Marketing •Shop Floor Control •Trade and Logistics

Microsoft certification most valuable courses in Axapta

Microsoft certification most valuable courses in Axapta Exam MB6-817: Trade and Logistics in Microsoft Dynamics AX 2009  • Exam MB6-818: Financials in Microsoft Dynamics AX 2009  • Exam MB6-819: Development Introduction in Microsoft Dynamics AX 2009  • Exam MB6-820: Installation and Configuration in Microsoft Dynamics AX 2009  • Exam 70-432: TS: Microsoft SQL Server 2008 Implementation and Maintenance

Number Sequence creation through code in axapta

Number sequence Creation Add method current form where number sequence needed NumberSeqFormHandler numberSeqFormHandler; NumberSeqFormHandler numberSeqFormHandler() { if (!numberSeqFormHandler) { numberSeqFormHandler = NumberSeqFormHandler::newForm(ProdParameters::numRefSrNo().NumberSequence,element,TableName_ds,fieldnum(TableName,SrNo)); } return numberSeqFormHandler; } public void delete() { element.numberSeqFormHandler().formMethodDataSourceDelete(); super(); } public void write() { ; ttsbegin; super(); element.numberSeqFormHandler().formMethodDataSourceWrite(); ttscommit; } void create(boolean _append = false, boolean extern = false) //If created externally { ; element.numberSeqFormHandler().formMethodDataSourceCreatePre(); super(_append); if (!extern) { element.numberSeqFormHandler().formMethodDataSourceCreate(); } //GODInstrumentCalibrationHeader.Responsibility =curuserid(); To par

Axapta Coverage

As per my experience and knowledge following places in India have nice axapta market. 1 Mumbai- Here Godrej infotech,TCS(Tata consultancy Services),NDS,L &T Info-tech etc working well in Axapta and lot of other companies also implemented Axapta. 2. Ahmedabad:- DevITP(Dev Information technology Pvt. Ltd) Ahmedbad,Indusa etc 3. Vadodara:- TDW,GERI(Gujarat Engineering Research Institute)  implemented Axapta etc 4. Pune 5. Bangalore 6. Hyderabad-Accenture 7. Delhi 8. Jaipur 9.Udaipur 10.Gurgaon 11.New Delhi 12-Gandhinagar-Gujarat Other Place like  Jamnagar etc also have good scope for axapta.

call form through class in axapta

This code is to how to call any form using class.I think this is challenging for new developpers. create mathod create form protected FormRun createForm(identifiername identifiername) { Args args; FormRun formRun; ; args = new Args(); args.caller(this); formRun = new MenuFunction(identifiername, MenuItemType::Display).create(args); formRun.run(); formRun.wait(); return formRun; } Public boolean prompt() { Object formRun; ; formRun = this.createForm(menuitemdisplaystr(Formaname)); Code = formrun.formmathod(); return formRun.okPressed(); }

create dialog in class of axapta

This code is to create dialog in class using axapta code . Mostly new developer directly call dialog through report but by using class you can use to lot of report. DialogField DialogFromDate,DialogToDate; // DateTimeUtil fromDate; // DateTimeUtil toDate; FromDate fromDate; ToDate toDate; DateTimeAccepted tmpdate; protected Object dialog() { Object ret; DialogRunbase dialog; //= super(); ; Dialog = super(dialog); Dialog.caption("Percentage Calculation"); DialogFromDate = dialog.addField(typeid(FromDate)); DialogToDate = dialog.addField(typeid(ToDate)); return dialog; } public boolean getFromDialog() { boolean ret; ret = super(); fromDate=dialogFromDate.value(); toDate=dialogToDate.value(); return ret; } public container pack() { container ret; // ret = super(); return ret; } public boolean unpack(container packedClass) { boolean ret; ret = super(packedClass); return re

Date to datetime conversion in axapta

This code is Date to datetime conversion in axapta. Try this way. date fromDate ; Timezone timezone = DateTimeUtil::getUserPreferredTimeZone(); ; fromDate=mkdate(1,mthofyr(str2date('1/9/2009',123)),Year(str2date('1/9/2009',123))); abc.DateTime1>= datetobeginUtcDateTime(fromDate,timezone)

Adding Progress bar in form or report in axapta

Adding Progress bar in form or report in axapta is not so tough I just try this code. SysOperationProgress progress,progressexcel; str tmpb,tmpogroup,tmpo,tmpb; ; progressexcel = new SysOperationProgress(); progressexcel.setCaption('Progress'); progressexcel.setText('Printing To Excel..Please Wait'); super(); startLengthyOperation(); element.oQuery(); element.close(); progressexcel.setTotal(8000); excelApplication = new COM("excel.application"); excelWorkBooks = excelApplication.workBooks(); excelWorkBook = excelWorkBooks.add(); excelWorkSheets = excelWorkBook.worksheets(); excelApplication.visible(false); excelWorkSheet = excelApplication.activeSheet(); styles = excelWorkBook.styles(); style = styles.add('MyStyle'); font = style.font(); font.bold(true); range = excelWorkSheet.Range("A1:C1"); range.style('MyStyle'); range.MergeCells(true); range.value2(CompanyI

How to concatenate multiple range from projTable

How to concatenate multiple range from projTable. Just use simple code here. static void concatenatemultipleRange(Args _args) { ProjTable ProjTable1; QueryBuildDataSource qbds; Query q = new Query(); queryRun queryRun1; str range; str 20 InventId; ProjTable ProjTable2; QueryBuildDataSource qbds1; Query q1 = new Query(); queryRun queryRun2; ProjTable ProjTable3; QueryBuildDataSource qbds2; Query q2 = new Query(); queryRun queryRun3; date startdate; ; startdate = str2date('31/07/2010',123); range = ''; q = new Query(); qbds = q.addDataSource(tablenum(ProjTable)); // dimensionRange = ProjTable_ds.query().dataSourceTable(TableNum(ProjTable)).addRange(FieldId2Ext(FieldNum(ProjTable, Dimension),2)); qbds.addRange(FieldId2Ext(FieldNum(ProjTable, Dimension),2)).value(''); qbds.addRange(fieldNum(ProjTable, Created)).value(strFmt('((Created >= %1)', date2StrXpp(startdate))); qbds.add

Use of Switch case and add data field to grid at runtime

Use of Switch case and add data field to grid at runtime. public void Bind_Total() { FormControl FC1, FC2, FC3, FC4, FC5, FC6, FC7; delete_from SD_AllDetails_Total; select sum(NoofSP), sum(Area), sum(ApproxYield), sum(ActualYield), sum(NoLot), from SD_AllDetails_1; SD_AllDetails_Total1.NoofSP = SD_AllDetails_1.NoofSP; SD_AllDetails_Total1.Area = SD_AllDetails_1.Area; SD_AllDetails_Total1.ApproxYield = SD_AllDetails_1.ApproxYield; SD_AllDetails_Total1.ActualYield = SD_AllDetails_1.ActualYield; SD_AllDetails_Total1.NoLot = SD_AllDetails_1.NoLot; SD_AllDetails_Total1.insert(); SD_AllDetails_Total_ds.refresh(); SD_AllDetails_Total_ds.reread(); SD_AllDetails_Total_ds.research(); GridTotal = GroupTotal.addControl(FormControlType::Grid, "GridTotal", StaticText); GridTotal.dataSource(SD_AllDetails_Total_ds.id()); while select * from SD_Columns3 order by SD_Columns3.ID where SD_Columns3.YesNo == true && SD_Columns3.GroupBy == false { switch(SD_Co

Add range in job using axapta

Add range in job using axapta static void JobForRangeInAx(Args _args) { // variable declaration str string; Query query; QueryRun queryRun; QueryBuildDataSource queryBuildDataSource; QueryBuildRange queryBuildRange; CustTable custTable; ; //start logic of program if ( hasSecurityKeyAccess(securityKeyNum(SysDevelopment), AccessType::Edit) ) { query = new Query(); queryBuildDataSource = query.addDataSource(TableNum(CustTable)); queryBuildRange = queryBuildDataSource.addRange(FieldNum(CustTable,AccountNum)); queryBuildRange.value("1000..2000"); queryRun = new queryRun(query); if (queryRun.prompt()) { while (queryRun.next()) { custTable = queryRun.get(TableNum(CustTable)); print custTable.AccountNum; } } } select count(Name) from custTable; string = custTable.Name; Box::info(string,'title','help'); }

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

Use of query build datasource in job and range

Use of query build datasource in job and range static void SelectCustomerJobQuery(Args _args) { Query query; QueryBuildDataSource queryBuildDatasource; QueryBuildRange queryBuildRange; QueryRun queryRun; Counter recordsFound; custTable cust; ; query = new Query(); queryBuildDataSource =query.addDataSource(tableNum(custTable)); queryBuildDataSource.addSortField(fieldNum(custTable,Name)); queryBuildRange =queryBuildDataSource.addRange(fieldNum(custTable,city)); queryRun = new QueryRun(query); /*while (queryRun.next()) { cust= queryRun.get(tablenum(custTable)); print cust.Name; }*/ if (queryRun.prompt()) { while (queryRun.next()) { recordsFound++; cust= queryRun.get(tablenum(custTable)); print cust.Name; } } info(strFmt("Customers found: %1", recordsFound)); pause; }

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(); }

DictTable example in axapta

This is sample code for DictTable example in axapta static void Job24(Args _args) { DictField df; extendedTypeId eti; DictType dt; date _date = 28\08\2008; ; df = new DictField(tablenum(Address), fieldnum(Address, AddrTableId)); info(strFmt('%1 %2', Year(_date), MthOfYr(_date) )); if (df) { eti = df.typeId(); if (0 != eti) { dt = new DictType(eti); if (dt) { print strfmt("The field is based on %1.", dt.name()); } } else { print "The field is not based on an extended data type."; } } pause; }

Export from custTable to Excel file in axapta

To Export Records from custTable to Excel  file in  axapta You can try following code. static void ExportingFields4mCustTable(Args _args) { CustTable CustTableLocal; SysExcelApplication excelApp; SysExcelWorkSheet excelWorksheet; SysExcelRange excelRange; SysExcelCells excelCells; SysExcelCell excelCell; ComVariant cellValue; Int i=1; ; excelApp = SysExcelApplication::construct(); cellValue = new ComVariant() ; excelApp.workbooks().add(); excelWorksheet = excelApp.worksheets().itemFromNum( 1 ); excelCells = excelWorksheet.cells(); while select * from CustTableLocal { excelCells.item(i+4,4).value(cellValue.bStr(CustTableLocal.AccountNum)); excelCells.item(i+4,5).value(cellValue.bStr(CustTableLocal.Name)); i++; } excelApp.visible(true); }

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

passing variable through form to report in axapta

This is a sample code for passing variable through form to report in axapta public void sumss() { str ss; int tmp; ; //Element.selectMode(Element.control(Control::Sunny_CustMaster_NO));; for (Table1 = Table1_ds.getFirst(true) ? Table1_ds.getFirst(true) : Table1_ds.cursor(); Table1; Table1 = Table1_ds.getnext()) { tmp = Table1.SrNo; } iss = num2str(tmp,2,2,4,2); } call on clicked event of button Args args = new Args(); ; for (Table1_obj1 = Table1_ds.getFirst(true) ? Table1_ds.getFirst(true) : Table1; Table1_obj1; Table1_obj1 = Table1_ds.getNext()) { args.record(Table1_obj1); element.sumss(); args.parm(iss); new MenuFunction(menuitemoutputstr(Traveling_Voucher), MenuItemType::Output).run(args); } super(); Pass to report like this super(); //psum = element.args().record(); // sumss = element.args().parm("acc"); iss = element.args().parm(); element.SumRes(iss); Table12 = element.args

Create user groups in Microsoft dynamics axapta

1. From an Microsoft Dynamics AX client, click Administration > Setup > User groups. 2. On the Groups tab, press CTRL+N to create a new group. 3. Enter an identification in the Group column (required). For example, Fin for Finance or HR for Human Resources. 4. Enter a name in the User group name column (required). For example Finance Department or Human Resources Department. 5. Click the Users tab. 6. Select users in the Remaining users list box and click the left-arrow button (<) to move the selected users into the Selected users list box. All users moved into the Selected users list box are added to the current group. 7. Press CTRL+S to save changes.

Steps to configuring IIS service manager

1. To open IIS Services Manager, click Start > All Programs > Administrative tools > Internet Information Services Manager. 2. In IIS Manager, navigate to the virtual root DynamicsWebService. 3. Click Action > Properties. 4. On the Directory tab, click Create. 5. Select the Application Pool created when you set up the application integration server. For additional information, see Install an application integration server. 6. For Execute permissions, select Scripts only. 7. Set the local path permissions to read by selecting the Read check box in the Local path section. 8. Navigate to Directory Security and clear Anonymous. Select Integrated. 9. On the ASP.NET tab, select ASP Version 2.0. If the ASP.NET tab does not appear, you must uninstall and reinstall ASP.NET in IIS using the following steps: a. Click Start > Run. b. Type cmd. c. In the Command Prompt window, type: cd your-system-directory\Microsoft.NET\Framework\v2.0.50727. and press ENTER.

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

Steps to Creating a view in axapta

Steps to Creating a view in axapta  1. First, we locate the Views node under the Data Dictionary in the AOT. 2. Right-click on the Views node and select New View. A new view will be created. You can open its properties by right-clicking and selecting Properties. 3. Change the name of the view to firstCust second and give it a label that describes the contents of the view. 4. The views can actually use queries that have already been created as a base for the data selection. This is done in the Properties of the view by choosing the query from the Query property. However, in our example, we will create the view from scratch. 5. Under the Metadata node, right-click on the Data Sources node and select New Data Source 6. Select the newly created data source and enter firstTable in the table property. The name of the data source will automatically change to firstTable_1, which is normal. 7. Under the firstTable data source, find the Data Sources node, right-click on it, and select

Joining data sources in a query in axapta

Joining data sources in a query in axapta InnerJoin Will return the records where the joined data sources have matching values in the joined fields. For example: By using the firstTable as the primary data source and using secondTable as the joined data source, the inner join will fetch all records from the firstTable where there is a corresponding record in the secondTable. The corresponding records in secondTable will also be fetched. OuterJoin Will return all the records from the joined table even if they don't match the joined field. For example: Compared to the example using the InnerJoin, this will return all records from the firstTable, but also records from the secondTable that does not have a match in the firstTable. ExistsJoin This is just like the InnerJoin, except the records from the joined data source are not returned. They are only used to filter the primary data source. For example: In our example, it will only return records in the firstTable where there

How can we Delete duplicate records of table in axapta

delete duplicate in axapta .If there is duplicate record in table then use this job to delete duplicate. If two name like sks and sks then one will be delete and one will remain. static void deleteduplicate(Args _args) { Set fieldSet = new set(Types::Integer); // create dictindex from the unique index DictIndex dictIndex = new DictIndex( tablenum(_RegistrationDetails), indexnum(_RegistrationDetails, Index1)); ; // these are the fields from the index // add them to a set fieldSet.add(fieldnum(_RegistrationDetails, _RegistrationNo)); // fieldSet.add(fieldnum(YourTable, YourTableFieldId2)); // set allow duplicates ReleaseUpdateDB::indexAllowDup(dictIndex); // delete duplicate records ReleaseUpdateDB::deleteDuplicatesUsingIds(tablenum(_RegistrationDetails), 0, fieldSet); // reenable index ReleaseUpdateDB::indexAllowNoDup(dictIndex); info("done"); }

Keywords list for Axapta bloggers

Add date range value from dialog to report ,Add multiple range and multiple table lookup ,Add range ,add run time control in axapta ,BI Design Suite ,BI Design Suite integrates with Microsoft Dynamics AX. Logistica ,Call Import data file in button in axapta ,Call other for on button clicked event in axapta ,Check exist item validation in table using axapta ,code Bind user to particular office in axapta application ,Code to add dialog and get value from dialog box using Axapta . Create and delete folder using axapta x++ code ,create folder ,Create Graph and load data to graph using axapta ,create lookup runtime in axapta form ,Create Organization Chart in axapta ,datasource in axapta using code in report ,Delete_from command to delete from table in axapta ,Display data of particular division and circles and filter data separated by comma ,Division BI Design Suite integrates with Microsoft Dynamics AX. Logistica ,Example of Fetch Method in Axapta ,Fetch function in Microsoft Dynamics

Filter value in lookup in payment journal invoice id as per customer in invoice bill using axapta

Filter value in lookup in payment journal invoice id as per custmer in invoice bill public void lookup() { SysTableLookup tableLookup; QueryBuildRange rangeTransDate; QueryBuildRange VillageCode,ItemId,DistCode,TalukaCode; QueryBuildRange CropId; QueryRun queryRun; QueryBuildDataSource qbds,qbds1,qbr,qbr1,qbr2; Query q = new Query(); Query q1 = new Query(); QueryBuildLink QueryBuildLink1,QueryBuildLink2; boolean flg; ; tableLookup = SysTableLookup::newParameters(tableNum(CustInvoiceTable),this); qbr = q.addDataSource(tableNum(CustInvoiceTable)); if(LedgerJournalTrans_AccountNum.valueStr() != "" ) { qbr.addRange(fieldnum(CustInvoiceTable,InvoiceAccount)).value(queryValue(LedgerJournalTrans_AccountNum.valueStr())); } tableLookup.parmQuery(q); tableLookup.addLookupfield(fieldNum(CustInvoiceTable,InvoiceId)); tableLookup.performFormLookup(); }

create lookup runtime in axapta form

This is a sample code to create lookup runtime in axapta form public void lookup() { SysTableLookup tableLookup; QueryBuildDataSource qbds, qbds1; QueryBuildLink QueryBuildLink1; Query q = new Query(); ; tableLookup = SysTableLookup::newParameters(tableNum(_Taluka),this); qbds = q.addDataSource(tablenum(_Taluka)); qbds.addRange(fieldnum(_Taluka, _DistrictCd)).value(District.valueStr()); tableLookup.parmQuery(q); tableLookup.addLookupfield(fieldNum(_Taluka,_TalukaCd)); tableLookup.addLookupfield(fieldNum(_Taluka, _TalukaName)); tableLookup.performFormLookup(); }

Concatenating Query range values in form datasource using axapta

Taking value in range by concatenating values in form and use of data source in form public void insert_tmpVillage() { QueryBuildDataSource qbds, qbds1, qbdsid, qbdsid1; Query q = new Query(); Query qid = new Query(); QueryBuildLink QueryBuildLink1; QueryBuildLink QueryBuildLink2; queryRun queryRun1; queryRun queryRun2; _BlockVillage _BlockVillage1; str range; QueryBuildRange qbr; Query query; QueryRun qr; ; Office = _Block.Office; TechYear = _Block.Year; Crop = _Block.CropId; season = _Block.Season; if(District.valueStr() != '' && Taluka.valueStr() != '') { qbdsid = qid.addDataSource(tablenum(_Block)); qbdsid.addRange(fieldnum(_Block, Office)).value(Office); qbdsid.addRange(fieldnum(_Block, Year)).value(TechYear); qbdsid.addRange(fieldnum(_Block, CropId)).value(Crop); qbdsid.addRange(fieldnum(_Block, Season)).value(queryValue(season)); qbdsid1 = qbdsid.addDataSource(tablenum(_Bloc

Display data of particular division and circles and filter data separated by comma

Display data of particular division and circles and filter data separated by comma public void UserRigths() { currentUserId = curUserId(); select * from sysCompanyUserInfo where sysCompanyUserInfo.UserId == currentUserID; if(sysCompanyUserInfo) { if(sysCompanyUserInfo.EmplId != "") { while select * from EmplTable2 where EmplTable2.EmplId == sysCompanyUserInfo.EmplId { d1 = System.Convert::ToString(EmplTable2.Dimension[2]); } if(d1 != "") { while select * from _OrganizationChart2_1 where _OrganizationChart2_1.WareHouseCode == d1 { _Office_type = _OrganizationChart2_1.Office_type; } } if (d1 != "") { if ((enum2str(_Office_type) == "Sachivalaya") || (enum2str(_Office_type) == "CE") || (enum2str(_Office_type) == "Circle") ) { while select * from _OrganizationChart2_2 where _OrganizationChart2_2.ParentWareHouseCode == d1 { OfficeName += _OrganizationC

Delete_from command to delete from table in axapta

As with the insert_recordset and update_recordset operators, there is also an option for deleting a chunk of records. This operator is called delete_from and is used as the next example shows: static void Delete_FromExample(Args _args) { CarTable carTable; ; delete_from carTable where carTable.Mileage == 0; }

Get current financial year from date and To date in axapta

public str getFinyear_To() { yy= 0; mm =0; mm3=""; DtFrm = todt; strdtfrm = date2str(todt, 123, 2, 4, 2, 4, 4); mm = str2int(substr(strdtfrm, 4, 2)); yy = str2int(substr(strdtfrm, 7, 4)); yy5 = str2int(substr(strdtfrm, 7, 4)); mm3 = substr(strdtfrm, 4, 2); if (mm <= 4) { yy--; } finYrTo = int2str(yy) + '-';  yy++; finYrTo += substr(int2str(yy),3,2); return finYrTo; }  public str getFinyear_From() { ; DtFrm = frmdt;  strdtfrm = date2str(dtfrm, 123, 2, 4, 2, 4, 4); mm = str2int(substr(strdtfrm, 4, 2)); yy = str2int(substr(strdtfrm, 7, 4)); mm2= substr(strdtfrm, 4, 2); yy4 = str2int(substr(strdtfrm, 7, 4));  if (mm <= 3) { yy--; }  finYrFrom = int2str(yy) + '-';  yy++; finYrFrom += substr(int2str(yy),3,2); return finYrFrom; } 

Get current financial year in axapta

display str CurFinYr() { DtFrm = frmdt; strdtfrm = date2str(dtfrm, 123, 2, 4, 2, 4, 4); yy = str2int(substr(strdtfrm, 7, 4)); Fyy = substr(int2str(yy),3,2); DtTo = toDt; strdtto = date2str(DtTo, 123, 2, 4, 2, 4, 4); yy = str2int(substr(strdtto, 7, 4)); Tyy = substr(int2str(yy),3,2); CurFinYr=Fyy+" - "+Tyy; return CurFinYr; }

Get previous financial year in axapta

By using this method you can Get previous financial year in axapta. If you are using from date and to date in ax and these date belongs to current financial year but your requirement is to get 1 year back financial year then you can use this method. Display str PrevFinYr() { str f,t; DtFrm = frmdt; strdtfrm = date2str(dtfrm, 123, 2, 4, 2, 4, 4); yy = str2int(substr(strdtfrm, 7, 4)); Fyy = substr(int2str(yy),3,2); DtTo = toDt; strdtto = date2str(DtTo, 123, 2, 4, 2, 4, 4); yy = str2int(substr(strdtto, 7, 4)); Tyy = substr(int2str(yy),3,2); if ((str2int(fyy)-1)<10) {  f="0"+int2str(str2int(fyy)-1);  }  else  { t=int2str(str2int(fyy)-1);  }  if ((str2int(tyy)-1)<10) { t="0"+int2str(str2int(tyy)-1); } else {  t=int2str(str2int(tyy)-1); }  PrevFinYr=f +" - "+ t; return PrevFinYr; }

Binding user to particular office in axapta application

This is simple filter code for Binding  user to particular office in axapta application. Like current user is adam and you want to show him only one employee date then you can use filter methodology this way. public void filter1() { UserId currentUserId; SysCompanyUserInfo sysCompanyUserInfo; _ServiceDetails2 _ServiceDetails2; EmplTable emplTable; InventLocationId inventLoc; Date LastDate; RecId RecId; currentUserId = curUserId(); select * from sysCompanyUserInfo where sysCompanyUserInfo.UserId == currentUserID; if(sysCompanyUserInfo) { if(sysCompanyUserInfo.EmplId != "") { select * from emplTable where emplTable.EmplId == sysCompanyUserInfo.EmplId; if(emplTable) { if(emplTable.EmplId != "") { while select * from _ServiceDetails2 where _ServiceDetails2.EmplId == emplTable.EmplId { if(LastDate == any2date(0)) { LastDate = _ServiceDetails2.DateTo; RecId = _ServiceDetails2.RecId; } else { if(LastDate < _ServiceDetails2.DateTo) { L

Insert and delete item from container in Axapta

This is a sample of code how to Insert and delete item from container in Axapta. This code you can apply in form or report for your purpose. static void Datatypes_container_functions(Args _args) { container con; ; // conins - Insert values to the container con = conins(con, 1, "Toyota"); con = conins(con, 2, 20); con = conins(con, 3, 2200.20); con = conins(con, 4, "BMW"); con = conins(con, 5, 12); con = conins(con, 6, 3210.44); // condel - Delete the third and the fourth element // from the container con = condel(con, 3, 2); // conpeek - Read values from the container info(conpeek(con,1)); info(conpeek(con,2)); info(conpeek(con,3)); info(conpeek(con,4)); // connull - Reset the container con = connull(); // conlen - Get the length of the container info(strfmt("Length: %1",conlen(con))); }

Fetch Method to make Trial balance quickly

This is simple Fetch Method to make Trial balance quickly. Some times standard trial balance does not match due to wrong customization of application so there may be data problem in ledger balance table then you can make trial balance by using LedgerTrans table. Performance of report will be slow but it can give accurate result. public boolean fetch() { Query q = new Query(); QueryBuildDataSource qbds; ; q= this.query(); qbds = q.dataSourceTable(tablenum(LedgerTrans)); qbds.addSortField(fieldnum(LedgerTrans,AccountNum)); rangeTransDate =qbds.findRange(fieldnum(LedgerTrans,TransDate)); purpose1 = qbds.findRange(FieldId2Ext(FieldNum(LedgerTrans, Dimension),3)); if(!rangeTransDate.value()) { rangeTransDate.value(queryRange(dateMin,dateMax)); fromdate= dateMin; todate =dateMax; } else { value=rangeTransDate.value(); if(strfind(value,".",1,11) != 0) { mindate1 =strdel(value,strfind(value,".",1,11),strle

strscan function to scan string characters in axapta

This is a sample of code how to use of strscan function in axapta to scan string from string. void ArrayAccount() { //s = ""; // len = strlen( _s ); // pos = strfind( _s, _delimeter, len, -len ); // s = strdel( _s, 0, pos ); cntAc =1; name = System.Convert::ToString(BHead); Accountname[cntAc] = LedgerTable::find(name).AccountName; len = strlen(name); for (i = 0; i<=len;i++) { pos = strscan( name, ".", strlen( name ), 0 - strlen( name ) ); fName = strdel( name, pos, strlen( name ) - pos + 1 ); lastName = strdel( name, 1, pos ); if (FName != "") { name = fName; cntAc++; Accountname[cntAc] = LedgerTable::find(name).AccountName; } } }

Add date range value from dialog to report through code in Axapta

This is a sample code to Add date range value from dialog to report through code in Axapta. This code is to use in report of Ax. Getfromdialog and dialog is overridden method in Ax report. public boolean getFromDialog() { ; cmbOfficeCode = dialogOffice.value(); // cmbProjId = dialogProjId.value(); DateType = dialogDateType.value(); fromdate = dialogfromdate.value(); todate = dialogtodate.value(); return true; } public Object dialog(Object _dialog) { DialogRunbase dialog = _dialog; ; cmbOfficeCode = InventId; cmbProjId = ProjId1; dialogOffice = dialog.addFieldValue(typeid(InventLocationId), cmbOfficeCode); //dialogProjId = dialog.addFieldValue(typeid(ProjId), cmbProjId); dialogDateType = dialog.addFieldValue(typeid(Irrigation_Date),"Select Date", "Select Date"); dialogFromDate = dialog.addFieldValue(typeid(FromDate), fromDate); dialogToDate = dialog.addFieldValue(typeid(ToDate), toDate); return dialo

Create Organization hierarchy Chart in axapta

These are method to create organization hierarchy chart in Axapta public class FormRun extends ObjectRun { CCFormTreeDatasource treeDatasource; } void InsertinTemp() { TmpOrganizationChart2 TmpOrganizationChart2_1; _OrganizationChart2 _OrganizationChart2_1; ; /*hile select _OrganizationChart2_1 { while select forupdate TmpOrganizationChart2_1 where TmpOrganizationChart2_1.WareHouseCode==_OrganizationChart2_1.WareHouseCode { TmpOrganizationChart2_1.delete(); } }*/ Delete_from TmpOrganizationChart2_1; While select _OrganizationChart2_1 { TmpOrganizationChart2_1.WareHouseCode=_OrganizationChart2_1.WareHouseCode; TmpOrganizationChart2_1.ParentWareHouseCode=_OrganizationChart2_1.ParentWareHouseCode; TmpOrganizationChart2_1.Office_type=_OrganizationChart2_1.Office_type; TmpOrganizationChart2_1.Name=InventLocation::find(_OrganizationChart2_1.WareHouseCode).Name; TmpOrganizationChart2_1.insert(); } } public void

Load data to chart in axapta

If you want to Load data to show as a  chart in axapta then you need to drag chart control to form group or tab then you can store data in to tables. You can use while loop to take data in looping and at the time of loop execution you can call data to graph. This is a simple method which you can call on init method of form to show data initially. void createGraph() { //SalesLine salesline; // graphics graphics,graphics1; int i,k; str month; // date createddate; #macrolib.ChartFx ; graphics1 = Graphics::newGraphicsTitlesLayout(ChartX, 100, 200,'Title', 'X', 'Y', 'z',1 ,1, 1, 1); graphics1.create(); graphics1.parmTitle(""); graphics1.parmTitleXAxis('Year'); graphics1.parmTitleYAxis('Weight(Kg.)'); ChartX.Chart3D(true); ChartX.toolBar(true); //graphics.Gallery(9); ChartX.Gallery(6); ChartX.DataEditor(true); ChartX.grid(1); ChartX.BackColor(16777215); ChartX.ToolBa

Use temporary variable to distinct or group by element to fetch record in Axapta

Fetch method is override method of report in axapta. You can Use temporary variable to distinct or group by element to fetch record in Axapta . By this example you can get only hints or idea to use in your report. public boolean fetch() { Query q = new Query(); QueryBuildDataSource qbds; ; q= this.query(); qbds = q.dataSourceTable(tablenum(LedgerTrans)); // qbds = q.addDataSource() qbds.addSortField(fieldnum(LedgerTrans,AccountNum)); rangeTransDate =qbds.findRange(fieldnum(LedgerTrans,TransDate)); purpose1 = qbds.findRange(FieldId2Ext(FieldNum(LedgerTrans, Dimension),3)); if(!rangeTransDate.value()) { rangeTransDate.value(queryRange(dateMin,dateMax)); fromdate= dateMin; todate =dateMax; } else { value=rangeTransDate.value(); if(strfind(value,".",1,11) != 0) { mindate1 =strdel(value,strfind(value,".",1,11),strlen(value)); maxdate1 =strDel(value,strfind(value,".",1,11)+1,-(strfind(val

Use multiple table link through code in Axapta report

public boolean fetch() { str 50 tmpregno; QueryBuildDataSource qbds,qbds1,qbds2; QueryBuildRange queryBuildRange; QueryBuildRange rangeTransDate; QueryRun qr1; QueryBuildLink QueryBuildLink_1; query q = new Query(); query q1 = new Query(); ; // frmdt = str2date("01/05/2010",123); // todt = str2date("30/05/2010",123); q = this.query(); q1 = this.query(); qbds2 = q.addDataSource(tablenum(_Registration)); qbds1 = qbds2.addDataSource(tablenum(_RegistrationDetails)); qbds = qbds1.addDataSource(tablenum(_Register4)); qbds.joinMode(JoinMode::InnerJoin); QueryBuildLink_1 = qbds.addLink(fieldNum(_RegistrationDetails, _RegistrationNo), fieldNum(_Register4, RegistrationNo)); qbds.relations(true); queryBuildRange = qbds.addRange(fieldNum(_Register4, ProcessDate)); rangeTransDate = qbds.findRange(fieldnum(_Register4,ProcessDate)); /* if(!rangeTransDate.value()) { rangeTransDate.value(queryRange(dateMin,dateMax)); if (dateMin ==str2date(

Add multiple range and multiple table lookup

This is a sample code to Add multiple range and multiple table lookup in Axapta. public void lookup() { SysTableLookup tableLookup; QueryBuildRange rangeTransDate; QueryBuildRange vlgCode,ItemId,DistCode,talCode; QueryBuildRange CropId; QueryRun queryRun; QueryBuildDataSource qbds,qbds1,qbr,qbr1,qbr2; Query q = new Query(); Query q1 = new Query(); QueryBuildLink QueryBuildLink1,QueryBuildLink2; _TmpLookup _TmpLookup1; InventTable InventTable_1; boolean flg; ; tableLookup = SysTableLookup::newParameters(tableNum(_TableDetails),this); qbr = q.addDataSource(tableNum(_TableDetails)); qbr2=qbr.addDataSource(tablenum(_Inspection1)); qbr2.joinMode(Joinmode::NoExistsJoin); QueryBuildLink2 = qbr2.addLink(fieldnum(_TableDetails, _TableNo),fieldnum(_Inspection1,TableNo)); // qbr2.addRange(fieldnum(_TableDetails,_TableNo)).value(queryNotValue(SysQuery::valueEmptyString())); qbr2.relations(true); if(tmpfilter.DistrictCode != &quo