//Get cube related data in AX 2012//Prerequisite//Add new references node in AOTMicrosoft.AnalysisServices.AdomdClientstatic void SSLSSASCubeData(Args _args){str cubeConnectionString, cubeQuery, value;int i, rowCount;System.Data.DataTable dataTable;System.Data.DataRowCollection collection;System.Data.DataRow row;System.Object object;Microsoft.AnalysisServices.AdomdClient.AdomdConnection Conn;Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter dataAdapter;cubeConnectionString = 'Data Source=SSAS_SERVER;Catalog=SalesCube';cubeQuery = 'Select SalesNum from SalesCube';dataTable = new System.Data.DataTable();Conn = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection(cubeConnectionString);dataAdapter = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter(cubeQuery, Conn);dataAdapter.Fill(dataTable);collection = dataTable.get_Rows();rowCount = collection.get_Count();for (i = 0; i < rowCount; i++){row = collection.get_Item(i);object = row.get_Item(0);value = object.ToString();info(strFmt('%1. %2', i+1, value));}Conn.Close();}
Monday, September 11, 2017
Get SSAS cube related data in AX 2012
Package & Model & Project & Overlaying & Extension in Dynamics 365 ERP
//Dynamics 365
//Directory for XML file
/AosServices/PackageLocalDirecotry/
Packages:
Packages
(Model store) are deploy-able solutions that have
inter-dependencies with other packages.
Package are same as model store in ax 2012. In ax 2012 it is DB, In Dynamics 365 for finance and operations is in DLL file. New package may refers to multiple
existing package
Model:
Each model must be belong to any one of
package. Model to package is always having one to one
relation.
Projects:
Each model can consists of multiple
projects. But one same projects can't be access in
another Model. If developer wants to access multiple
model elements from different model,
then needs to do proceed with multiple project.
Overlaying:
Overlaying is when you modify existing
code by changing the system behavior.
For example:
1) overlaying the Method on
the Table. Right click on the object and click
Customize.
2) Developer wants to attach new
work-flow in Std. Form means, then have to go for overlay customization.
(Note this can be achieve in extension also, for reduce upgrades, Migration, Merging code)
3) Over Laying - Customization in Base Package
3) Over Laying - Customization in Base Package
Extension:
Extensions are used in Dynamics 365 for
operations much more flexible. Extensions allow
you to leave the system behavior, but adding your piece to it. In some
cases you have to overlay but try
Create Runable class in Dynamics 365 for finance and operations
//Create Runable class in Dynamics 365 for finance and operations
class SSLRunClassTest
{
public static void main(Args _args)
{
Query query;
QueryBuildDataSource qbds;
QueryRun queryRun;
ProjTable projTable;
query = new Query();
qbds = query.addDataSource(tableNum(ProjTable));
qbds.addSortField(fieldNum(ProjTable, Name),SortOrder::Ascending);
qbds.addRange(fieldNum(ProjTable,Type)).value(queryValue(1);
queryRun = new QueryRun(query);
while (queryRun.next())
{
projTable = queryRun.get(tableNum(ProjTable));
info(strFmt("%1, %2, %3",projTable.ProjId,projTable.Name,projTable.Type));
}
}
}
class SSLRunClassTest
{
public static void main(Args _args)
{
Query query;
QueryBuildDataSource qbds;
QueryRun queryRun;
ProjTable projTable;
query = new Query();
qbds = query.addDataSource(tableNum(ProjTable));
qbds.addSortField(fieldNum(ProjTable, Name),SortOrder::Ascending);
qbds.addRange(fieldNum(ProjTable,Type)).value(queryValue(1);
queryRun = new QueryRun(query);
while (queryRun.next())
{
projTable = queryRun.get(tableNum(ProjTable));
info(strFmt("%1, %2, %3",projTable.ProjId,projTable.Name,projTable.Type));
}
}
}
Consuming External Web services(WSDL link) in Dynamics 365 for finance and operations
//Consuming External Web services in Dynamics 365 for finance and operations
//Sample WSDL URL
http://currencyconverter.kowabunga.net/converter.asmx
//Create new project
//Create new class libarary and names as SSLExternalWebservices
//Add a service reference under the References in newly created project.
/Use above sample WSDL service
Named as SSLCurrencyConverterServices
//Write in class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SSLExternalWebServices.SSLCurrencyConverterService;
using System.ServiceModel;
//class name currencyConverter
public string getCurrencyRate(String cur1, string cur2)
{
BasicHttpBinding httpBinding = new BasicHttpBinding();
EndpointAddress endPoint = new EndpointAddress(@"http://currencyconverter.kowabunga.net/converter.asmx");
var soapClient = new ConverterSoapClient(httpBinding,endPoint);
var usdToinr = soapClient.GetConversionRate(cur1.ToString(), cur2.ToString(),DateTime.Now);
return usdToinr.ToString();
}
//Add a new Operation Project in your solution Name it SSLExternalWebServiceDAX.
//In the Reference node, right-click and add a new reference. You can choose the
project and it will add the dll file automatically in the reference node.(SSLExternalWebservices)
//Add a runnable class in your Operation Project, name it SSLConsumeServiceInDAX, and add a namespace of
using SSLExternalWebServices;
Public static void Main(Args _args)
SSLExternalWebServices.currencyConverter currencyCoverter = new SSLExternalWebServices.currencyConverter();
var convRate = str2Num(currencyCoverter.getCurrencyRate("USD","INR"));
info(strFmt("%1", convRate));
}
//Save all your code and build the solution. Set this project SSLExternalWebServiceInDAX
//As a startup project and class SSLConsumeServiceInDAX
//Run a solution and Test it now
//Sample WSDL URL
http://currencyconverter.kowabunga.net/converter.asmx
//Create new project
//Create new class libarary and names as SSLExternalWebservices
//Add a service reference under the References in newly created project.
/Use above sample WSDL service
Named as SSLCurrencyConverterServices
//Write in class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SSLExternalWebServices.SSLCurrencyConverterService;
using System.ServiceModel;
//class name currencyConverter
public string getCurrencyRate(String cur1, string cur2)
{
BasicHttpBinding httpBinding = new BasicHttpBinding();
EndpointAddress endPoint = new EndpointAddress(@"http://currencyconverter.kowabunga.net/converter.asmx");
var soapClient = new ConverterSoapClient(httpBinding,endPoint);
var usdToinr = soapClient.GetConversionRate(cur1.ToString(), cur2.ToString(),DateTime.Now);
return usdToinr.ToString();
}
//Add a new Operation Project in your solution Name it SSLExternalWebServiceDAX.
//In the Reference node, right-click and add a new reference. You can choose the
project and it will add the dll file automatically in the reference node.(SSLExternalWebservices)
//Add a runnable class in your Operation Project, name it SSLConsumeServiceInDAX, and add a namespace of
using SSLExternalWebServices;
Public static void Main(Args _args)
SSLExternalWebServices.currencyConverter currencyCoverter = new SSLExternalWebServices.currencyConverter();
var convRate = str2Num(currencyCoverter.getCurrencyRate("USD","INR"));
info(strFmt("%1", convRate));
}
//Save all your code and build the solution. Set this project SSLExternalWebServiceInDAX
//As a startup project and class SSLConsumeServiceInDAX
//Run a solution and Test it now
Building & consume Custom service in Dynamics 365 for finance and operations (To initiate Dynamics 365 AX from externally for CRUD operation)
//Building & consume Custom service in Dynamics 365 for finance and operations
//Create new project
//Create new class for data contract
[DataContractAttribute]
class SSLBalanceDataContract
{
TransDate transDate;
SSLAccount accountNum;
DataAreaId dataAreaId;
[DataMemberAttribute('DateTransactionDate'),
SysOperationLabelAttribute(literalStr("@SYS11284"))]
public TransDate parmTransDate(TransDate _transDate = transDate)
{
transDate = _transDate;
return transDate;
}
[DataMemberAttribute('Company'),
SysOperationLabelAttribute(literalStr("@SYS11284"))]
public DataAreaId parmDataAreaId(DataAreaId _dataAreaId =dataAreaId)
{
dataAreaId = _dataAreaId;
return dataAreaId;
}
[DataMemberAttribute('SSLAccount'),
SysOperationLabelAttribute(literalStr("Account number"))]
public SSLAccount parmSSLAccount(SSLAccount _accountNum = accountNum)
{
accountNum = _accountNum;
return accountNum;
}
}
//Create new class for service operations
class SSLBalanceService
{
[AifCollectionType('return', Types::Real,extendedTypeStr(Amount))]
public Amount processData(SSLBalanceDataContract _SSLBalanceDataContract)
{
QueryRun queryRun;
SSLTable SSLTableget;
Amount balance;
System.Exception ex;
try
{
if(_SSLBalanceDataContract.parmDataAreaId())
{
changecompany(_SSLBalanceDataContract.parmDataAreaId())
{
var query = new Query();
var qbds = query.addDataSource(tableNum(SSLTable));
qbds.addRange(fieldNum(SSLTable,SSLAccount)).value(_SSLBalanceDataContract.parmSSLAccount());
queryRun = new queryRun(query);
while(queryRun.next())
{
SSLTableget = queryRun.get(tableNum(SSLTable));
balance = SSLTableget.balanceCur();
}
}
}
}
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
}
return balance;
}
}
//Create new service object named as SSLBalanceService and set the following properties on it
Class SSLBalanceService
External name SSLBalanceService
//Right-click on the Service Operations node under our service
SSLBalanceService , select new service operations and set the
following properties:
Method processData
Name processData
//Create a new object under the Service groups node and mention new name i
Name Service
Service SSLBalanceServiceGrp
//Build the project and, on successful build, our web service is available to communicate AX from external
//Now new web service is deployed on SOAP and JSON endpoints automatically.
//Consuming custom services in SOAP - sample code here
https://github.com/Microsoft/Dynamics-AX-Integration/commit/18006cba62649477c2fbe7fb691c263207253be5
//Create new project
//Create new class for data contract
[DataContractAttribute]
class SSLBalanceDataContract
{
TransDate transDate;
SSLAccount accountNum;
DataAreaId dataAreaId;
[DataMemberAttribute('DateTransactionDate'),
SysOperationLabelAttribute(literalStr("@SYS11284"))]
public TransDate parmTransDate(TransDate _transDate = transDate)
{
transDate = _transDate;
return transDate;
}
[DataMemberAttribute('Company'),
SysOperationLabelAttribute(literalStr("@SYS11284"))]
public DataAreaId parmDataAreaId(DataAreaId _dataAreaId =dataAreaId)
{
dataAreaId = _dataAreaId;
return dataAreaId;
}
[DataMemberAttribute('SSLAccount'),
SysOperationLabelAttribute(literalStr("Account number"))]
public SSLAccount parmSSLAccount(SSLAccount _accountNum = accountNum)
{
accountNum = _accountNum;
return accountNum;
}
}
//Create new class for service operations
class SSLBalanceService
{
[AifCollectionType('return', Types::Real,extendedTypeStr(Amount))]
public Amount processData(SSLBalanceDataContract _SSLBalanceDataContract)
{
QueryRun queryRun;
SSLTable SSLTableget;
Amount balance;
System.Exception ex;
try
{
if(_SSLBalanceDataContract.parmDataAreaId())
{
changecompany(_SSLBalanceDataContract.parmDataAreaId())
{
var query = new Query();
var qbds = query.addDataSource(tableNum(SSLTable));
qbds.addRange(fieldNum(SSLTable,SSLAccount)).value(_SSLBalanceDataContract.parmSSLAccount());
queryRun = new queryRun(query);
while(queryRun.next())
{
SSLTableget = queryRun.get(tableNum(SSLTable));
balance = SSLTableget.balanceCur();
}
}
}
}
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
}
return balance;
}
}
//Create new service object named as SSLBalanceService and set the following properties on it
Class SSLBalanceService
External name SSLBalanceService
//Right-click on the Service Operations node under our service
SSLBalanceService , select new service operations and set the
following properties:
Method processData
Name processData
//Create a new object under the Service groups node and mention new name i
Name Service
Service SSLBalanceServiceGrp
//Build the project and, on successful build, our web service is available to communicate AX from external
//Now new web service is deployed on SOAP and JSON endpoints automatically.
//Consuming custom services in SOAP - sample code here
https://github.com/Microsoft/Dynamics-AX-Integration/commit/18006cba62649477c2fbe7fb691c263207253be5
Creating New Batch Job in Dynamics 365 for finance and operations
//Creating Batch Job in Dynamics 365 for finance and operations
//Create new project
//Create new class
Class Code:
class SSBatchTest extends RunBaseBatch
{
[SysEntryPointAttribute(false)]
public void processRecords()
{
//To do: Business logic
}
}
//Before make sure all requires setup has been setup properly for batch processing like batch server, group
//Create Action menu type - property to be set:
Type - Class
Object - SysOperationServiceController
EnumTypeParameter - SysOperationExecutionMode
EnumParameter - Synchronous
Parameters - SSBatchTest.processRecords
//Create new project
//Create new class
Class Code:
class SSBatchTest extends RunBaseBatch
{
[SysEntryPointAttribute(false)]
public void processRecords()
{
//To do: Business logic
}
}
//Before make sure all requires setup has been setup properly for batch processing like batch server, group
//Create Action menu type - property to be set:
Type - Class
Object - SysOperationServiceController
EnumTypeParameter - SysOperationExecutionMode
EnumParameter - Synchronous
Parameters - SSBatchTest.processRecords
Subscribe to:
Posts (Atom)
Export label custom content
GRID => Properties "Export Label" => "SalesReportMexico" To get download file with custom naming.
-
Posting Vendor invoice based on Product receipt public void postPurchaseInvoiceJournal() { VendPackingSlipJour vendP...
-
protected void executePostingDataPerOrder(str _salesId) { SalesFormLetter_PackingSlip salesFormLetter_PackingSlip...
-
Class SAN_PickingQtyOrder { public static void DoPickQtyForOrderLine(SalesLine _SalesLine, Qty _qtyPicked) { Inve...

