24 December 2013

Microsoft Dynamics AX 2015 Next release in 2014 or 2015 Dynamics AX 2013-2015 Road map


Microsoft Dynamics AX 2015 Road map

Click here to download the PDF file




The next major release of Microsoft Dynamics AX is code named ’Rainier’. It is a new cloud
optimized platform for deployments in private and public cloud as well as on-premises. It will
underline and the enable next generation of user experiences. Breakthrough application lifecycle
management with adoption of ‘what you need, when you need it’ along with new levels of
process and business insight will make ‘Rainier’ a true breakthrough release!
The first elements of ‘Rainier’ are expected to be available in Q4 CY2014 with key investments
areas including:

 Next Generation User Experience - a context-sensitive Windows 8 experience based on
HTML5 client technology
 Cloud Delivered – with a focus on enabling a “what you need, when you need it” approach
via Windows Azure and/or Windows Server
 Best in class lifecycle management – regardless of deployment choice from on-premise,
hybrid to full cloud
With ‘Rainier’ we will continue to deliver the most intuitive and simple solution for your
customer interactions, your people and your business by innovating and building out the
functionality footprint across retail, distribution, manufacturing, services and public sector.

Features

a. Cloud Based Solutions
b. Platform independence - Browser enabled clients
c. AD Federation and more integration with Azure
d. More investments on Visual Studio (Development Environment will be VS)
e. Application Development targetting any OS through Rainier
f. No longer need to invest on Sharepoint hosting as Enterprise portal will be eliminated
g. 3 key pillars - New client, Cloud Readiness, New Development Stack
h. No RPC based communication (Atleast, now it's assured that the event logs won't get full by RPC errors which was the case with AX 2009)
i. Programming language will still be X++ but everything will be .net compiled
j. Capability to expose updatable views using OData
k. HTML 5 based Web Client so more faster and richer experience

So, all looks exciting for the next major release of Dynamics AX which would be somewhere in end of 2014 or early 2015!

15 December 2013

Query range in AX 2012 /2009

dateQBR.value(queryRange(FromDateEdit.dateValue(), ToDateEdit.dateValue()));

-> below query you can write in form ->DataSource-> ExecuteQuery()

this.query().dataSourceName("QualityInspectionControl").addRange(fieldNum(QualityInspectionControl,QuaityChecked)).value(queryvalue(NoYes::No));
this.query().dataSourceTable(tablenum(QualityInspectionControl)).addRange(fieldnum(QualityInspectionControl,QuaityChecked)).value(queryVal

query range in ax 2009 date function

Fist add following peace of line in init() method


criteriaApproved = this.query().dataSourceTable(tablenum(VendTrans)).addRange(fieldnum(VendTrans,Approved));

followin line in execute query()

dateQBR.value(strfmt('(CustTrans.TransDate >= %1) && (CustTrans.TransDate <= %2)', Date2StrXpp(01\01\2010), Date2StrXpp(31\10\2010)));

06 December 2013

AX 2012 Enterprise Portal Development Cookbook AX 2012 EP

AX 2012 Enterprise Portal Development Cookbook

Please click here to download Enterprise Portal Development Cookbook

X++ code for Ledger journal posting with one line / journal posting in AX

Example class for reference: \Classes\TutorialJournalCheckPost\main

Example: Using Ledger Journal
The following is an example of creating a journal with one journal line and then
posting the journal.

static void ExampleLedgerJournal(Args _args)
{
LedgerJournalName LedgerJournalName;
LedgerJournalTable ledgerJournalTable;
LedgerJournalTrans ledgerJournalTrans;
LedgerJournalCheckPost ledgerJournalCheckPost;
NumberSeq numberseq;
LedgerJournalNameId LedgerJournalNameId = 'GenJrn';
BankAccountID BankAccountID = 'EUR OPER';
ledgerAccount offsetAccount = '601500';
amountCur amountCur = 102;
;
ttsbegin;
// Find a ledgerJournalName record
select firstonly LedgerJournalName
where LedgerJournalName.JournalName ==
LedgerJournalNameId;
//Created the ledgerJournalTable
ledgerJournalTable.JournalName =
LedgerJournalName.JournalName;
ledgerJournalTable.initFromLedgerJournalName();
ledgerJournalTable.Name = 'Hotel';
ledgerJournalTable.insert();
numberseq =
NumberSeq::newGetVoucherFromCode(ledgerJournalName.VoucherS
eries);
ledgerJournalTrans.Voucher = numberseq.voucher();
//Generate the transaction line
ledgerJournalTrans.JournalNum =
ledgerJournalTable.JournalNum;
ledgerJournalTrans.CurrencyCode = 'EUR';
ledgerJournalTrans.ExchRate =
Currency::exchRate(ledgerJournalTrans.CurrencyCode);
ledgerJournalTrans.AccountNum = BankAccountID;
ledgerJournalTrans.AccountType =
LedgerJournalACType::Bank;
ledgerJournalTrans.AmountCurCredit = amountCur;
ledgerJournalTrans.TransDate = today();
ledgerJournalTrans.Txt = 'Room Stay';
ledgerJournalTrans.OffsetAccount = offsetAccount;
ledgerJournalTrans.OffsetAccountType =
LedgerJournalACType::Ledger;
ledgerJournalTrans.insert();
info(strfmt('Journal Id:
%1',ledgerJournalTable.JournalNum));
//Post the Journal
ledgerJournalCheckPost =
ledgerJournalCheckPost::newLedgerJournalTable(ledgerJournal
Table,NoYes::Yes);
ledgerJournalCheckPost.run();
ttscommit;
}

X++ coding for Ledger Voucher posting with example / Ledger Voucher posting / voucher posting in AX

Example Class for Reference : \Classes\TutorialLedgerVoucher\runSalesPost
Example: Using LedgerVoucher
The following job posts a petty cash disbursement for a payment for a stapler and
some stamps. The accounts and amounts are set in the variable declaration.
Usually these would be obtained from parameters, user input or a calculation.

static void ExampleLedgerVoucher(Args _args)
{
LedgerVoucher ledgerVoucher;
LedgerVoucherTransObject ledgerVoucherTransObject;
Dimension dimension;
NumberSeq numSeq;
NumberSequenceCode NumberSequenceCode =
'Acco_18';
ledgerAccount accountNumPetty = '110180';
// Petty cash
ledgerAccount accountNumOffsetOffice =
'606300'; // Office Supplies
ledgerAccount accountNumOffsetPostage =
'606500'; // Postage
amountMST amountPetty = 55;
amountMST amountOffice = 50;
amountMST amountPostage = 5;
;
numSeq =
NumberSeq::newGetNumFromCode(NumberSequenceCode);
ttsbegin;
//First Step - Create Voucher
ledgerVoucher =
ledgerVoucher::newLedgerPost(DetailSummary::Summary,
SysModule::Ledger,
LedgerParameters::numRefLedgerExchAdjVoucher().NumberSequen
ce) ;
//Second Step - Create Voucher Number
ledgerVoucher.AddVoucher(LedgerVoucherObject::newVoucher(nu
mseq.num(),
today(),
Sysmodule::Ledger,
LedgerTransType::None));
//Create the first Transaction - this is the credit
side of the transaction (-55)
//The other two DR transactions should total to the CR
otherwise it won't post.
ledgerVoucherTransObject =
LedgerVoucherTransObject::newCreateTrans(
ledgerVoucher.findLedgerVoucherObject(),
LedgerPostingType::LedgerJournal,
accountNumPetty, // Ledger Account
dimension,
CompanyInfo::standardCurrency(),
-
amountPetty, // Amount
0, //
TableId
0); //
ReciID
ledgerVoucherTransObject.parmTransTxt("Petty cash
disbursement");
ledgerVoucher.addTrans(ledgerVoucherTransObject);
//Create the second Transaction
ledgerVoucherTransObject =
LedgerVoucherTransObject::newCreateTrans(
ledgerVoucher.findLedgerVoucherObject(),
LedgerPostingType::LedgerJournal,
accountNumOffsetOffice,
dimension,
CompanyInfo::standardCurrency(),
amountOffice, // Amount
0,
// TableId
0);
// ReciID
ledgerVoucherTransObject.parmTransTxt("Red stapler");
ledgerVoucher.addTrans(ledgerVoucherTransObject);
//Create third Transaction
ledgerVoucherTransObject =
LedgerVoucherTransObject::newCreateTrans(
ledgerVoucher.findLedgerVoucherObject(),
LedgerPostingType::LedgerJournal,
accountNumOffsetPostage,
dimension,
CompanyInfo::standardCurrency(),
amountPostage,
0,
// TableId
0);
// ReciID
ledgerVoucherTransObject.parmTransTxt("Stamps");
ledgerVoucher.addTrans(ledgerVoucherTransObject);
//Last Step - To Balance Voucher and Close
ledgerVoucher.end();
numseq.used();
ttsCommit;
}

03 December 2013

Refreshing form's datasource without affecting cursor position / How to retain cursor position? in AX

WE can do in two ways

1.Just calling the Research method by passing true boolean value
MyTable_ds.research(true); // boolean value retain the cursor position
------------
2.you can use method setPosition() and getPosotion()
{
int position;
;
position= MyTable_ds.getPosition();
MyTable_ds.research();
MyTable_ds.setPosition(position);
}



Happy Daxing
Sunil

02 December 2013

Surrogate key

Hi,

A surrogate key is a AX -generated record identifier. In Dynamics Ax terms, it is a RecId field, used as the primary key of a table.

Happy Daxing
SUNIL

01 December 2013

how to deploy ssrs reports in ax 2012 by using management shell

1.Type the following command to deploy the report. For example, let's deploy
the CustTransList report:
Publish-AXReport -ReportName CustTransList

2.To deploy multiple reports using PowerShell, we can use the following command:

Publish-AXReport -ReportName Sales, SalesAnalysis

3.To deploy all the reports using PowerShell, we can use the following command:
Publish-AXReport –ReportName *

4.To deploy reports to a different Report Server, we can use the following command:
Publish-AXReport – ReportName -ServiceAOSName
-ServicesAOSWSDLPort

===================================

1) Open Windows Powershell as Administrator
2) Type the below command :-

To Deploy specific report:
C:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -Module ApplicationSuite -ReportName PurchPurchaseOrder* -PackageInstallLocation "C:\AosService\PackagesLocalDirectory"
To Deploy all Reports:
 c:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -PackageInstallLocation "c:\AosService\PackagesLocalDirectory"


30 November 2013

how to deploy AX 2012 SSRS report by using management shell

1. Click on Start | Administrative tools.
2. Right-click on Microsoft Dynamics AX 2012 Management Shell.
3. Click on Run as administrator.
4. Enter the following PowerShell command to deploy.

Importing AxUtilLib
Importing AxUtilLib.PowerShell
Importing Microsoft.Dynamics.Administration
Importing Microsoft.Dynamics.AX.Framework.Management
PS C:\Windows\system32> publish-axreport -reportName "CustTransList"
Deploying reports and related artifacts.


AOSName : 01@WIN-Q8ELR4RAAKK
ConfigurationId : SSRS
Description :
Default : True
ReportServerFolder : DynamicsAX
ReportServerName : WIN-Q8ELR4RAAKK
ReportServerInstanceName :
ReportServerManagerUrl : http://win-q8elr4raakk/Reports
ReportServerWebServiceUrl : http://win-q8elr4raakk/ReportServer

ReportName : CustTransList
Designs : {CustTransList.Report}
Assemblies : {CustTransListReport.BusinessLogic.dll, SharedComp
onentsSRS.BusinessLogic.dll, DrillThroughCommon.dl
l}
Datasources :
DesignDeploymentStatus : {Success}
AssemblyDeploymentStatus : {Success, Success, Success}
DataSourceDeploymentStatus :

Deployment completed.


PS C:\Windows\system32>

26 November 2013

How to get records by using tableId

static void TableRecByRecID(Args _args)
{
Common common;
DictTable dictTable;
#define.tableNo(77)// 77 is CustTable id
;
dictTable = new DictTable(#tableNo);
common = dictTable.makeRecord();
select common;
info(strfmt("%1",common.RecId));
}

25 November 2013

Reread(), refresh() and research()

Hi,

reread Rereads the active record from the database.
refresh Refreshes the view of all the records currently held in the
data source.
research Refreshes the complete query defined in the data source.

25 October 2013

02 October 2013

Dynamics AX Caching and CacheLookup Property

Hi Guys,

Click here This link will take you to good article to know about the Caching mechanism in DynamicsAX.



Thanks

01 October 2013

Optimistic Concurrency Control and Pessimistic Concurrency Control in Dynamics AX Occ enabled

OCC:

Optimistic Concurrency Control (OCC) helps increase database performance
Optimistic Concurrency only locks records from the time when the actual update is performed.

PCC

Pessimistic Concurrency Control locks records as soon as they are fetched from the database for an update.

OCC Enabled: Yes

17 September 2013

How to generate RECID through SQL Server database in AX

Insert the data in AX from other sql server database through SP.

ALTER procedure [dbo].[SP_GetAXRecID](@axRecid bigint output)
as
begin
update [Server].Databse.dbo.systemsequences
set @axRecid = nextVal = nextVal + 1
from [Server].Databse.dbo.systemsequences where
dataareaid = 'dat' and name = 'SEQNO'
end

14 September 2013

Display all AOT Table in lookup / get all table ids in lookup / List of table ids in lookup

static void lookupAOTTables(FormStringControl _ctrl)
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(UtilidElements), _ctrl);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange nameQBR, typeQBR;
;
sysTableLookup.addLookupfield(fieldnum(UtilidElements, Id));
sysTableLookup.addLookupfield(fieldnum(UtilidElements, Name));

queryBuildDataSource = query.addDataSource(tablenum(UtilidElements));


//nameQBR = queryBuildDataSource.addRange(fieldnum(UtilidElements, name));
//nameQBR.value('Cust*');


typeQBR = queryBuildDataSource.addRange(fieldnum(UtilidElements, recordType));
typeQBR.value(SysQuery::value(UtilElementType::Table));


sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

20 August 2013

AX 2012 Table inheritance with example

Step-1 Create a table called 'BaseTable'
Step-2 Set table property 'supportInheritance' to 'Yes'
Step-3 Create a filed name called 'InstanceRelationType' extends 'RelationType'
Step-4 Set table property 'InstanceRelationType' to 'InstanceRelationType'
Step-5 Create two filed called Id and Name as shown below screen
Step-6 Create another table called 'ChildTable'
Step-7 Set table property 'supportInheritance' to 'Yes'
Step-8 Set table property 'Extends' to 'BaseTable'
Step-9 Write a job to access the base table fields given below

static void dataInsert_BaseTable(Args _args)
{
BaseTable bt;
ChildTable ct;

ct.Id = '1000';
ct.Name = 'Test';
ct.insert();
}

AX 2012 Model store database and baseline model store

Model store database
The model store is the database where all application elements for Microsoft Dynamics AX are stored. Customizations are also stored in the model store. The model store replaces the Application Object Data (AOD) files that were used in earlier versions of Microsoft Dynamics AX.

Baseline model store
The baseline model store holds model store tables for the earlier version of the metadata and is used only during upgrade. The baseline model store is like the old folder in earlier versions of Microsoft Dynamics AX.

Note : In Microsoft Dynamics AX 2012 R2, the model store was moved into a database that is separate from the business database.

16 August 2013

X++ Code Optimzation performance tuning

X++ Code Optimzation
Following are the coding tips to improve your Axapta system's performance:
1. Smart Joins : Try to Use Joins instead of nested while loop
wherever possible.
2. Select Statement : Mention the field names in the select statement
instead of feteching entire row , this will reduce
data amount to transfer from database.
e.g " Select Itemid from inventTable "

3. Display Methods : Make sure that generic display methods should be
moved at table level and cached by
using"Formdatasource.cacheAddmethod".
4. Local caching : Use Variables for storing the constantly used
caculated values in loop , by doing so you can
reduce the calls to the database and different
layers.
5. Monitor the Database Calls : For bulk records
updation,deletion,insertion use
RecordSet Based operator like
update_recordset , delete_from and insert_recordset .
6. Aggregate Function: Use sum, avg, minof, maxof and count where
applicable. Because this can utilize the database’s
built-in function instead of calculating and analyse
data in Axapta.

15 August 2013

AIF Custom service atributes in AX

SysEntryPointAttribute:This is a mandatory attribute in methods that
are exposed as a service operation. It indicates
that the method is a service operation. Not
using this attribute will result in a service
group deployment failure.
An optional parameter specifies whether the
AOSAutorization setting on the tables will
be checked when this method is executed on
the server.
Ex:
[SysEntryPointAttribute(true)]
private void GetRecord(Str _titleId)
{
}
DataContractAttribute:Defines that the attributed class is used as a
data contract for a service.
Ex:
[DataContractAttribute]
private void GetRecord(Str _titleId)
{
}
DataMemberAttribute:Indicates that a parameter method is a data
member in a data contract for a service.
Ex:
[DataMemberAttribute]
private void GetRecord(Str _titleId)
{
}

AifCollectionTypeAttribute:This attributes specifies the type that is used
in a collection. It contains the name of the
parameter that is targeted and the types of the
objects that are contained in the collection.
Ex:
[AifCollectionTypeAttribute]
private void GetRecord(Str _titleId)
{
}

08 August 2013

Get Customer name and Vendor name in display method in 2012

Hi Friends,

Str name;

//Customer name
name = DirPartyTable::getName(CustTable.Party);

// Vendor Name
name = DirPartyTable::getName(VendTable.Party);

above peace of code can use in display method.

30 July 2013

23 May 2013

Create inventory journals through X++ code in AX 2009 / movement journal creating though X++ code

static void createInventoryJournal(Args _args)///and also it will import the data from the Excel
{
InventJournalNameId inventJournalNameId = "IMov";///Assign the journal Name
AxInventJournalTrans axInventJournalTrans;
InventJournalTable inventJournalTable;
Dialog dialog;
DialogField dialogField,dialogdate;
Filename filename;
COMVariant cOMVariant;
SysExcelApplication sysExcelApp;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell rCell;
int i,j,k;
SysOperationProgress simpleProgress;
Container filterCriteria;
#avifiles
;
sysExcelApp = SysExcelApplication::construct();///SysExcelApplication
workbooks = sysExcelApp.workbooks();///Workbooks

Dialog = new dialog();
dialogField = dialog.addField(typeId(FileNameOpen),'File Name');
filterCriteria = ['*.xls','*. xlsx'];//// To filter only Excel files
filterCriteria = dialog.filenameLookupFilter(filterCriteria);
dialog.run();
if(dialog.run())
fileName = dialogField.value();

cOMVariant = new COMVariant();
cOMVariant.bStr(fileName);

workBook = workBooks.add(cOMVariant);///Workbook
worksheets = Workbook.worksheets();///WorkSheets
worksheet = worksheets.itemFromNum(1);///WorkSheet
Cells = workSheet.cells();///Cells

i=2;
rCell = Cells.item(i,1);///rCell

if(fileName)
{
ttsBegin;
inventJournalTable.JournalNameId = inventJournalNameId;
inventJournalTable.initFromInventJournalName(InventJournalName::find(inventJournalNameId));
inventJournalTable.insert();
simpleProgress = SysOperationProgress::newGeneral(#aviUpdate,'Importing Transactions',100);///SysProgressOperation
while(RCell.Value().bStr() != '')
{
j++;
simpleProgress.incCount();
simpleprogress.setText(strfmt("Transaction Imported: %1",i));
sleep(10);
simpleprogress.kill();
axInventJournalTrans = new AxInventJournalTrans();
axInventJournalTrans.parmJournalId(inventJournalTable.JournalId);
axInventJournalTrans.parmTransDate(systemdateget());
axInventJournalTrans.parmLineNum(j);
rCell = Cells.Item(i, 1);
axInventJournalTrans.parmItemId(RCell.value().bStr());
rCell = Cells.Item(i, 2);
axInventJournalTrans.axInventDim().parmInventSiteId(rCell.value().bStr());
rCell = Cells.Item(i, 3);
axInventJournalTrans.axInventDim().parmInventLocationId(rCell.value().bStr());
rCell = Cells.Item(i, 4);
axInventJournalTrans.parmQty(rCell.value().double());
rCell = Cells.Item(i, 5);
axInventJournalTrans.parmCostPrice(rCell.value().double());
axInventJournalTrans.save();
i++;
rCell = Cells.Item(i, 1);
}
ttsCommit;
}
}

16 May 2013

How to enable and use the "Run As" feature in Windows Server 2003

Enable the Secondary Logon Service

By default, the Secondary Logon service starts automatically when you start Windows. However, an administrator can disable the service. To enable the service if it is disabled:
Log on as Administrator or as a member of the Administrators group.
Click Start, point to Administrative Tools, and then click Computer Management.
Expand Services and Applications, and then click Services.
In the right pane, right-click Secondary Logon, and then click Properties.
Click the General tab.
In the Startup type box, click Automatic, and then click Start under Service status.
Click OK, and then close the Computer Management window.
Use Run As to Start a Program as Another User

To use the "Run as" feature to start a program as another user:
Locate the program that you want to start in Windows Explorer, the Microsoft Management Console (MMC), or Control Panel.
Press and hold down the SHIFT key while you right-click the .exe file or icon for the program, and then click Run as.
Click The following user.

In the User name and Password boxes, type the user name and password of the user whose credentials you want to use to run the program, and then click OK.
NOTE: You can also use the runas command from a command prompt. For more information, click Start, and then click Run. In the Open box, type cmd, and then click OK. At the command prompt, type runas /?, and then press ENTER.

01 March 2013

SysOperationProgress - using progress bar in operation

SysOperationProgress is a class to use operation progress indicator

find the below sample code for an example:

static void SysOperationProgress_PrimeNumber(Args _args)
{
#avifiles
boolean checkPrime,_showProgess = true;
SysOperationProgress progressBar = new SysOperationProgress();//
int counter,out;
;
counter = 1;
out = 1000;
while(counter < out)
{
checkPrime = ((counter mod 2)!=0 && (counter mod 3) !=0);

if(checkPrime)
{
info(strfmt("its a prime number %1",counter));
}
progressBar.setCaption(strfmt("Generating the prime number for %1",counter));
progressBar.setAnimation(#aviUpdate);//#AviFindFile);
progressBar.setText(strfmt("Processing %1 out of %2",counter,out));
counter++;
}
}

27 February 2013

New line or break lines with windows applications like OutLook,HTML and XML

When ever sending the email by using the parameters:
to show receive email line by line in out look have to use
while passing the parameter:

Ex:
while()
{
log = strfmt('Messge for body line'+ '');// to break lines when interfacing with windows applications

}
Class::emailNotification('abc@yahoo.com','xyx@yahoo.com','Subject txt',log)



//in log varialble there are multibple lines so
is the tab to break lines and show in out look mail.

Static void emailNotification(str fromEmail, str toEmail,str subject, str body)
{
SysMailer mailer = new SysMailer();
SysEmailParameters parameters = SysEmailParameters::find();
;
if (parameters.SMTPRelayServerName)
{
mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
else
{
mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
mailer.fromAddress(fromEmail);
mailer.tos().appendAddress(toEmail);
mailer.subject(subject);
mailer.htmlBody(body);
mailer.sendMail();
}
Thanks for reading..:-)

21 February 2013

Date Time / UTCDateTime

static void DateTime(Args _args)
{
UtcDateTime dateTime;
;
dateTime = DateTimeUtil::newDateTime(systemdateget(),DateTimeUtil::time(DateTimeUtil::getSystemDateTime()));
info(datetime2str(dateTime));

}

08 February 2013

X++ code to open a form or menuitem AXAPTA

how to open a form by using x++ code:

static void OpenDisplayMenuItem()
{
Args args = new Args();
;
args.record(VendTable::find("XYZ"));
new MenuFunction(MenuItemDisplayStr(VendTable),MenuItemType::Display).run(Args);
}

------
static void OpenForm()
{ FormRun formRun;
Args args = new Args();
;
args.name(formstr(VendTable));
args.record(CustTable::find("XYZ"));

formRun = ClassFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.wait();
}

07 February 2013

like operator in Axapta

To get matching words in query

static void Job587(Args _args)
{
CustTable custTable;

select custTable where custTable.Name like("*john*");// match with john
select custTable where custTable.Name like("*john");// end with with john
select custTable where custTable.Name like("john*");// start with john
info(custTable.Name);

}

Cannot edit a record in Sales orders (SalesTable). An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.


ttsbegin;
salesTable.reread() /* <--Have to call before update a record*/

if(salesTable.recid)
{
salesTable.update()
}
ttscommit;

02 February 2013

Calling the manu item name in form initiation


Calling the manu item name in form initiation

Form init method()

element.args().menuItemName() == menuitemDisplayStr(GPI_CopyProduct)

31 January 2013

Exception handling in AX / Try catch throw in AX

public boolean createExcelApp()
{
boolean ret = true;
;
try
{
sysExcelApplication = SysExcelApplication::construct();
if (sysExcelApplication == null)
{
ret = false;
throw Exception::Error;
}
}
catch (Exception::Error)
{
error("@SYS59928");
}
return ret;
}

=============UPdate exception=========

System.Exception ex;
        try
        {
            tableBuffer.field = value;
            tableBuffer.update();
        }
        catch(ex)
        {
            System.String messageEx = ex.Message;
            errorMessage = messageEx;
        }

30 January 2013

Dialog in class with batch job in AX/ working with batch job in AX

1. Class have to extend the RunbaseBatch
2. implement the Run() in this method we can call our method which is created for logic(upload()).
3. Implement the pack and unpack methods
4. Implement the dialog() method
5. Construct() method
6. getFromDialog() method
7. Main method
8. Description method
9. Validate method
10.canGoBatch()
11.canGoBatchJournal

--
class INU_UpdExtProcComplete extends runbasebatch
{
DialogField dlgField;
FilenameOpen filenameOpen;

#define.CurrentVersion(1)
#define.Version(1)
#localmacro.CurrentList
filenameOpen
#endmacro
}
--
public void run()
{
if(filenameOpen)
{
if(WINAPI::fileExists(filenameOpen))
this.upload();
else throw error("@SYS26757");
}
super();
}
--
client static INU_UpdExtProcComplete construct()
{
return new INU_UpdExtProcComplete();
}
--
public container pack()
{
return [#CurrentVersion,#CurrentList];
}
--
public boolean unpack(container packedClass)
{
Version version = Runbase::getVersion(packedClass);

switch(version)
{
case #CurrentVersion:
[version, #CurrentList] = packedClass;
break;
default:
return false;
}

return true;
}
--
public boolean getFromDialog()
{
boolean ret;

ret = super();

filenameOpen = dlgField.value();

return ret;
}
--
public Object dialog()
{
DialogRunbase dialog = super();
;
dlgField = dialog.addFieldValue(typeid(FilenameOpen),"","@IST10755","@IST10755");
return dialog;
}
--
void upload()
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row;
FileName filename;
TINS_PurchTable tINS_PurchTable;
PurchId purchId;
str dataArea;
;
row++;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
filename = filenameOpen;

try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error("@SYS19358");
}

workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();


do
{
row++;
purchId = cells.item(row, 1).value().bStr();
dataArea = cells.item(row, 2).value().bStr();

if(purchId)
{
ttsbegin;
select forupdate crosscompany purchTable
where purchTable.PurchId == purchId;
if(tINS_PurchTable.PurchId)
{
changecompany(dataArea)
{
purchTable.OneTimeVendor = Noyes::Yes;
purchTable.doupdate();
info("The purchase id %1 is updated successfully",purchTable.PurchId);

}
}
else
{
info(strfmt("@IST10757",purchId));
}
ttscommit;
}
else
{
throw error(strfmt("@IST10758"));
}
type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
}
--
public static void main(Args args)
{
INU_UpdExtProcComplete iNU_UpdExtProcComplete;
;
iNU_UpdExtProcComplete = INU_UpdExtProcComplete::construct();

if(iNU_UpdExtProcComplete.prompt())
iNU_UpdExtProcComplete.run();
}
--
static ClassDescription description()
{
return "@IST10759";
}
--
boolean validate()
{
boolean ret;

ret = super();

if(!winapi::fileExists(filenameOpen))
ret = checkFailed(strfmt("@SYS18678",filenameOpen));

return ret;
}
--
public boolean canGoBatch()
{
return true;
}
--
public boolean canGoBatchJournal()
{
return true;
}

CrossCompany ChangeCompany in AX how to get the record from different companies

Cross company and Change company

Job
PurchTable purchTable;

select forupdate crosscompany purchTable
where purchTable.PurchId == purchId;
if(purchTable.PurchId)
{
changecompany(dataArea)
{
purchTable.OneTimeVendor = Noyes::Yes;
purchTable.doupdate();
info("The purchase id %1 is updated successfully",purchTable.PurchId);
}
}

18 January 2013

Request for the permission of type 'InteropPermission' failed. / Error in AX InteropPermission



Request for the permission of type 'InteropPermission' failed.

The solution is for the construct() method, have run on client.





Ex:
client static INU_SalesAgreementExpDelete Construct()
{
return new INU_SalesAgreementExpDelete();
}


when ever we are implementing runbasebatch, if we are using the com and sysmailer class have to run client on clientconstruct() method.

17 January 2013

Send an Email in AX / Email and alerts

Step 1. Admin-> setup->Email parameters
Step 2. Basic email template

SysEmail Errors please click here

static void sendEmail()
{
SysMailer mailer = new SysMailer();
SysEmailParameters parameters = SysEmailParameters::find();
str emailFrom = "abc@gmailcl.com";//sysuserInfo::find(curUserId(),false).Email;
InteropPermission permission = new InteropPermission(InteropKind::ComInterop);
str _emailTo;
str _subject;
str _bodyText;
;
_emailTo = "xyz@gmail.com";
_subject = "Mail";
_bodyText = "Aboutn Report";
CodeAccessPermission::revertAssert();
permission.assert();
if (_emailTo != "")
{
if (parameters.SMTPRelayServerName)
{
mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
else
{
mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
mailer.fromAddress(emailFrom);
mailer.tos().appendAddress(_emailTo);
mailer.subject(_subject);
mailer.htmlBody(_bodyText);
mailer.sendMail();
//SysInEtMail::sendEMail("Admin","En-us","abc@outlook.com"); // to email id
}
CodeAccessPermission::revertAssert();
}
==============================================
==============================================
static void emailThruSysMailer(Args _args)
{
SysMailer mailer = new SysMailer();
SysEmailParameters parameters = SysEmailParameters::find();
;

if (parameters.SMTPRelayServerName)
{
mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
else
{
mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}



mailer.fromAddress('xxx@123.com');
mailer.tos().appendAddress('aaa@123.com');
mailer.subject('AZZZ');
mailer.htmlBody('Comunicazione AX');


mailer.sendMail();
}

Trial balance export to Azure Blob Storage

The file will be automatically generated from D365 using a batch job. The trial balance file should include all dimensions. (Main-Dept-Cost ...