The purpose of this blog is for knowledge sharing and connect the relevant audience who are all into Microsoft Dynamics world.
Alfasith AX
Friday, August 30, 2013
Wednesday, August 28, 2013
Job to run the DP class in Dynamic AX
static void Job2runDP(Args _args)
{
TenantBalanceDetailsTmpTbl TenantBalanceDetailsTmpTbl; //temp table name
Query q;
TenantBalanceBuildingLevRDP dataProvider = new TenantBalanceBuildingLevRDP();
//DP class name
TenantBalanceBuildingLevContract contract = new TenantBalanceBuildingLevContract();
//contract class name
contract.parmNetBuildingId('CEU-000022');
//parameter that you passing in contract class
q = dataProvider.parmQuery();
dataProvider.parmDataContract(contract);
dataProvider.processReport();
TenantBalanceDetailsTmpTbl = dataProvider.getTenantBalanceDetailsTmpTbl();
while select TenantBalanceDetailsTmpTbl group by buildingId
{
print(TenantBalanceDetailsTmpTbl.BuildingId);
//Just print the filed that you want see the output
print(TenantBalanceDetailsTmpTbl.TotalCredit);
print(TenantBalanceDetailsTmpTbl.TotalDebit);
print(TenantBalanceDetailsTmpTbl.BalanceCredit);
print(TenantBalanceDetailsTmpTbl.BalanceDebit);
}
pause;
}
{
TenantBalanceDetailsTmpTbl TenantBalanceDetailsTmpTbl; //temp table name
Query q;
TenantBalanceBuildingLevRDP dataProvider = new TenantBalanceBuildingLevRDP();
//DP class name
TenantBalanceBuildingLevContract contract = new TenantBalanceBuildingLevContract();
//contract class name
contract.parmNetBuildingId('CEU-000022');
//parameter that you passing in contract class
q = dataProvider.parmQuery();
dataProvider.parmDataContract(contract);
dataProvider.processReport();
TenantBalanceDetailsTmpTbl = dataProvider.getTenantBalanceDetailsTmpTbl();
while select TenantBalanceDetailsTmpTbl group by buildingId
{
print(TenantBalanceDetailsTmpTbl.BuildingId);
//Just print the filed that you want see the output
print(TenantBalanceDetailsTmpTbl.TotalCredit);
print(TenantBalanceDetailsTmpTbl.TotalDebit);
print(TenantBalanceDetailsTmpTbl.BalanceCredit);
print(TenantBalanceDetailsTmpTbl.BalanceDebit);
}
pause;
}
Company image in SSRS 2012
1. Create a field as Companyimg in the temp table
2. In the properties of that field select the extended datatypes as "Bitmap".
use the below code to insert
TmpTbl.Comapanyimg = CompanyImage::findByRecord(CompanyInfo::find()).Image;
3. In Visual studio right click insert image .
a. Source : database
b. field select the companyimg
c. as bitmap format in format selection
2. In the properties of that field select the extended datatypes as "Bitmap".
use the below code to insert
TmpTbl.Comapanyimg = CompanyImage::findByRecord(CompanyInfo::find()).Image;
3. In Visual studio right click insert image .
a. Source : database
b. field select the companyimg
c. as bitmap format in format selection
Alternative color in SSRS 2012
Write in the expression in SSRS
=iif(RowNumber(Nothing) Mod 2, "White", "WhiteSmoke")
or use
=IIF(RunningValue(Fields!BuildingId.Value,COUNTDISTINCT,NOTHING) MOD 2 = 0,"WhiteSmoke","White")
//Here BuildingId is the group by value to have alternative color for every group.
=iif(RowNumber(Nothing) Mod 2, "White", "WhiteSmoke")
or use
=IIF(RunningValue(Fields!BuildingId.Value,COUNTDISTINCT,NOTHING) MOD 2 = 0,"WhiteSmoke","White")
//Here BuildingId is the group by value to have alternative color for every group.
Tuesday, August 27, 2013
Complete company name as expression in SSRS 2012
Expression in SSRS
=Microsoft.Dynamics.Framework.Reports.DataMethodUtility.PostDataMethodEvaluation(Microsoft.Dynamics.Framework.Reports.DataMethodUtility.UpdateAxContextPartition(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, Parameters!AX_RenderingCulture.Value, Parameters!AX_PartitionKey.Value),Microsoft.Dynamics.Framework.Reports.DataMethodUtility.GetFullCompanyNameForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value))
=Microsoft.Dynamics.Framework.Reports.DataMethodUtility.PostDataMethodEvaluation(Microsoft.Dynamics.Framework.Reports.DataMethodUtility.UpdateAxContextPartition(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, Parameters!AX_RenderingCulture.Value, Parameters!AX_PartitionKey.Value),Microsoft.Dynamics.Framework.Reports.DataMethodUtility.GetFullCompanyNameForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value))
To print only Today's date in Dynamic AX
job:,
date d;
d = today();
info(date2str(d,123,-1,-1,-1,-1,-1));
date d;
d = today();
info(date2str(d,123,-1,-1,-1,-1,-1));
Thursday, August 8, 2013
Wednesday, August 7, 2013
Debug the report in AX 2012
Hi
static void AlfasithDpDebug(Args _args)
{NQ_smmActivitiesDP NQ_smmActivitiesDP;
NQ_smmActivitiesDP dataprovider = new NQ_smmActivitiesDP();
NQ_smmactivitiesContract contract = new NQ_smmactivitiesContract();
smmActivitiesTmp smmActivitiesTmp;
query q;
contract.param_application(5637147580);
q = dataprovider.parmQuery();
//q.dataSourceTable(tableNum(SalesQuotationTable)).addRange(fieldNum(SalesQuotationTable, WorkerSalesResponsible)).value(""); //000545"); //"000042"); //"DNG998877");
q.dataSourceTable(tableNum(smmActivities)).addRange(fieldNum(smmActivities, responsibleworker)).value(""); //000545"); //"000042"); //"DNG998877");
dataprovider.parmDataContract(contract);
dataprovider.processReport();
smmActivitiesTmp = dataprovider.getsmmActivitiesTmp();
select firstOnly smmActivitiesTmp;
print smmActivitiesTmp.NQ_NContactperson;
//print smmActivitiesTmp;
pause;
}
Monday, August 5, 2013
lookup with joinning 2 tables in Dynamic AX
Implement this code in the lookup() method of the field where you need the lookup to be displayed.
NS: The same code can be written in three places to achieve the lookup.
1) Under AOT->Table->Method and cal this method from the form design where you want to display the lookup.
2) Form->Datasource->Table->Field->method
3) Form->Design->Field->Method.
public void lookup()
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource QbdsJoin;
// Instantiate sysTableLookup object using table which will provide the visible fields
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(TableName), this);
;
// Create the query.
qbds= query.addDataSource(tableNum(TableName));
qbds.addRange(fieldNum(TableName, FieldName)).value('Value');
//Join Table
QbdsJoin= qbds.addDataSource(tableNum(TableName2));
QbdsJoin.relations(true);
QbdsJoin.joinMode(JoinMode::ExistsJoin);
QbdsJoin.addRange(fieldNum(TableName2, Fieldname)).value('Value');
// Set the query to be used by the lookup form
sysTableLookup.parmQuery(query);
// Specify the fields to show in the form.
sysTableLookup.addLookupfield(fieldNum(TableName, FiledName));
sysTableLookup.addLookupfield(fieldId2Ext(fieldNum(TableName, Dimension), 1));
// Perform the lookup
sysTableLookup.performFormLookup();
}
NS: The same code can be written in three places to achieve the lookup.
1) Under AOT->Table->Method and cal this method from the form design where you want to display the lookup.
2) Form->Datasource->Table->Field->method
3) Form->Design->Field->Method.
public void lookup()
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource QbdsJoin;
// Instantiate sysTableLookup object using table which will provide the visible fields
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(TableName), this);
;
// Create the query.
qbds= query.addDataSource(tableNum(TableName));
qbds.addRange(fieldNum(TableName, FieldName)).value('Value');
//Join Table
QbdsJoin= qbds.addDataSource(tableNum(TableName2));
QbdsJoin.relations(true);
QbdsJoin.joinMode(JoinMode::ExistsJoin);
QbdsJoin.addRange(fieldNum(TableName2, Fieldname)).value('Value');
// Set the query to be used by the lookup form
sysTableLookup.parmQuery(query);
// Specify the fields to show in the form.
sysTableLookup.addLookupfield(fieldNum(TableName, FiledName));
sysTableLookup.addLookupfield(fieldId2Ext(fieldNum(TableName, Dimension), 1));
// Perform the lookup
sysTableLookup.performFormLookup();
}
Find methods() / inserting the values from one form where action is taking place is to be reflect in another form in Dynamic AX
Hi,
public void modified()
{
SMAServiceObjectTable smaServiceObjectTable;
SMAServiceOrderTable smaServiceOrderTable, smaServiceOrderTable1;
//Tables I used here and smaServiceOrderTable1 will act as datasource that I added
TableId loctableid;
super();
loctableid = element.args().record().TableId;
if (loctableid == tableNum(smaServiceOrderTable))
smaServiceOrderTable = element.args().record();
ttsBegin;
//Updated by Alfasith- This to display in OrderFormTable
select forUpdate smaServiceOrderTable1 where smaServiceOrderTable1.RecId == smaServiceOrderTable.RecId;
smaServiceOrderTable1.AssetId = smaServiceObjectTable::find(SMAServiceObjectRelation.ServiceObjectId).AssetId;
smaServiceOrderTable1.VehicleRegistrationNo = AssetTable::find(smaServiceObjectTable::find(SMAServiceObjectRelation.ServiceObjectId).AssetId).SerialNum;//SMAServiceObjectTable::find(SMAServiceObjectRelation.ServiceObjectId).vehicleRegistrationNo();
smaServiceOrderTable1.VehicleType = SMAServiceObjectTable::find(SMAServiceObjectRelation.ServiceObjectId).vehicleType();
smaServiceOrderTable1.Make = AssetTable::findByServiceObjectId(SMAServiceObjectRelation.ServiceObjectId).Make;
smaServiceOrderTable1.NQ_ServiceCentreCode = smaServiceObjectTable::find(SMAServiceObjectRelation.ServiceObjectId).serviceCentre();
smaServiceOrderTable1.update();
ttsCommit;
}
This above sample makes the sense of adding new fields in the form where two forms are involved and results should reflect in another form
public void modified()
{
SMAServiceObjectTable smaServiceObjectTable;
SMAServiceOrderTable smaServiceOrderTable, smaServiceOrderTable1;
//Tables I used here and smaServiceOrderTable1 will act as datasource that I added
TableId loctableid;
super();
loctableid = element.args().record().TableId;
if (loctableid == tableNum(smaServiceOrderTable))
smaServiceOrderTable = element.args().record();
ttsBegin;
//Updated by Alfasith- This to display in OrderFormTable
select forUpdate smaServiceOrderTable1 where smaServiceOrderTable1.RecId == smaServiceOrderTable.RecId;
smaServiceOrderTable1.AssetId = smaServiceObjectTable::find(SMAServiceObjectRelation.ServiceObjectId).AssetId;
smaServiceOrderTable1.VehicleRegistrationNo = AssetTable::find(smaServiceObjectTable::find(SMAServiceObjectRelation.ServiceObjectId).AssetId).SerialNum;//SMAServiceObjectTable::find(SMAServiceObjectRelation.ServiceObjectId).vehicleRegistrationNo();
smaServiceOrderTable1.VehicleType = SMAServiceObjectTable::find(SMAServiceObjectRelation.ServiceObjectId).vehicleType();
smaServiceOrderTable1.Make = AssetTable::findByServiceObjectId(SMAServiceObjectRelation.ServiceObjectId).Make;
smaServiceOrderTable1.NQ_ServiceCentreCode = smaServiceObjectTable::find(SMAServiceObjectRelation.ServiceObjectId).serviceCentre();
smaServiceOrderTable1.update();
ttsCommit;
}
This above sample makes the sense of adding new fields in the form where two forms are involved and results should reflect in another form
Validating two date fields in Dynamic AX
Hi,
1.Create two fields as UtcDateTimeEdit of table TableName
2.Name it InTime and OutTime.
3.In the init() of that datasource or form depends on requirements.
TableName.InTime = DateTimeUtil::getSystemDateTime();
TableName.OutTime = DateTimeUtil::getSystemDateTime();
//here making the system date and time to the that field.
3.Override the modified method by modified each of the fields.
public boolean modified()
{
boolean ret;
ret = super();
if(SMAServiceOrderTable.InTime > SMAServiceOrderTable.OutTime)
{
warning("In time cannot be greater than Out time");
SMAServiceOrderTable.InTime = DateTimeUtil::getSystemDateTime();
SMAServiceOrderTable.OutTime = DateTimeUtil::getSystemDateTime();
}
return ret;
}
1.Create two fields as UtcDateTimeEdit of table TableName
2.Name it InTime and OutTime.
3.In the init() of that datasource or form depends on requirements.
TableName.InTime = DateTimeUtil::getSystemDateTime();
TableName.OutTime = DateTimeUtil::getSystemDateTime();
//here making the system date and time to the that field.
3.Override the modified method by modified each of the fields.
public boolean modified()
{
boolean ret;
ret = super();
if(SMAServiceOrderTable.InTime > SMAServiceOrderTable.OutTime)
{
warning("In time cannot be greater than Out time");
SMAServiceOrderTable.InTime = DateTimeUtil::getSystemDateTime();
SMAServiceOrderTable.OutTime = DateTimeUtil::getSystemDateTime();
}
return ret;
}
Subscribe to:
Posts (Atom)
SQL code to upate one Legal entity banner to all the legal entity in D365
Hi, update companyimage set companyimage.Image = companyimageA.Image from ( select Image from companyimage where dataAreaid = 'USF...
-
Hi, AccountingDistribution ( accounting distribution 7452 ) AccountingDistributionEventTmp ( accounting distribution 100001 ) Accountin...
-
Hi, Create a EDT name it Gender then in properties enumType : //select the enum name Use the below code and enjoy. static v...