When there are Delivery type address are multiple to get default address:
Below is the class to use to get Default address.
Class: LogisticsLocationDefault
Reference: code:
\Data Dictionary\Tables\SalesTable\Methods\initFromCustTableMandatoryFields
location = LogisticsLocationDefault::findSimpleDefault(custTable, LogisticsLocationRole::findBytype(
LogisticsLocationRoleType::Delivery));
This blog is for Dynamics AX (AXAPTA) Developers,this will help you for your development issues. This site contains some Microsoft Dynamics AX X++ Codes for use in your day to day use.
13 October 2016
29 September 2016
String length align to export in Notepad AX 2012
public str strAlign(str _string, int _length)
{
str ret;
ret = _string + strRep(' ', _length);
ret = subStr(ret, 1, _length);
return ret;
}
{
str ret;
ret = _string + strRep(' ', _length);
ret = subStr(ret, 1, _length);
return ret;
}
27 July 2016
Get Dimension attribute value for Customer creation and for journal lines
Struct struct = new Struct();
container ledgerDimension;
DimensionDefault DimensionDefault;
custTable.company(custTableStagging.LegalEntity);
custTable.initValue();
name = custTableStagging.FirstName + " "+ custTableStagging.LastName;
//CustTable
custTable.AccountNum = NumberSeq::newGetNum(CustParameters::numRefCustAccount()).num();//customer.parmAccountNum();
custTable.CustGroup = custTableStagging.CustGroup;
custTable.Currency = CompanyInfo::standardCurrency();
if (custTableStagging.Region != '')
{
struct.add('Region', custTableStagging.Region);
ledgerDimension += struct.fields();
ledgerDimension += struct.fieldName(1);
ledgerDimension += struct.valueIndex(1);
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
custTable.DefaultDimension = DimensionDefault;
}
// custTable.KPMGPayeeName = name;
custTable.insert(DirPartyType::Organization, name);
============
container cont1,cont2,offSetAcctPattern;
int cnt;
DimensionDynamicAccount ledgerDim, offsetledgerDim;
if(mLegalEntity != '')
{
cnt++;
cont2 += ['LegalEntity',mLegalEntity];
}
if(mLocationFacility != '')
{
cnt++;
cont2 += ['LocationFacility',mLocationFacility];
}
if(mDepartment != '')
{
cnt++;
cont2 += ['Department',mDepartment];
}
if(mCustomerGroup != '')
{
cnt++;
cont2 += ['CustomerGroup',mCustomerGroup];
}
if(mBusinessUnit != '')
{
cnt++;
cont2 += ['BusinessUnit',mBusinessUnit];
}
if(mLocationType != '')
{
cnt++;
cont2 += ['LocationType',mLocationType];
}
if(mCompetency != '')
{
cnt++;
cont2 += ['Competency',mCompetency];
}
if(mProject != '')
{
cnt++;
cont2 += ['Project',mProject];
}
if(mRegion != '')
{
cnt++;
cont2 += ['Region',mRegion];
}
if(mWorker != '')
{
cnt++;
cont2 += ['Worker',mWorker];
}
if(ledgerJournalTrans.AccountType == LedgerJournalACType::Ledger)
{
cont1 += ['MainAccount',AccountNumb,cnt];
cont1 += cont2;
ledgerDim = AxdDimensionUtil::getLedgerAccountId(cont1);
if(ledgerDim == 0)
{
offSetAcctPattern = [AccountNumb,AccountNumb];
ledgerDim = AxdDimensionUtil::getLedgerAccountId( offSetAcctPattern);
}
ledgerJournalTrans.LedgerDimension = ledgerDim;
}
else
{
ledgerDim = DimensionStorage::getDynamicAccount(AccountNumb,ledgerJournalTrans.AccountType);
ledgerDimension += cnt;
ledgerDimension += cont2;
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
ledgerJournalTrans.LedgerDimension = ledgerDim;
LedgerJournalTrans.modifiedField(fieldNum(LedgerJournalTrans,LedgerDimension));
ledgerJournalTrans.DefaultDimension = DimensionDefault;
container ledgerDimension;
DimensionDefault DimensionDefault;
custTable.company(custTableStagging.LegalEntity);
custTable.initValue();
name = custTableStagging.FirstName + " "+ custTableStagging.LastName;
//CustTable
custTable.AccountNum = NumberSeq::newGetNum(CustParameters::numRefCustAccount()).num();//customer.parmAccountNum();
custTable.CustGroup = custTableStagging.CustGroup;
custTable.Currency = CompanyInfo::standardCurrency();
if (custTableStagging.Region != '')
{
struct.add('Region', custTableStagging.Region);
ledgerDimension += struct.fields();
ledgerDimension += struct.fieldName(1);
ledgerDimension += struct.valueIndex(1);
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
custTable.DefaultDimension = DimensionDefault;
}
// custTable.KPMGPayeeName = name;
custTable.insert(DirPartyType::Organization, name);
============
container cont1,cont2,offSetAcctPattern;
int cnt;
DimensionDynamicAccount ledgerDim, offsetledgerDim;
if(mLegalEntity != '')
{
cnt++;
cont2 += ['LegalEntity',mLegalEntity];
}
if(mLocationFacility != '')
{
cnt++;
cont2 += ['LocationFacility',mLocationFacility];
}
if(mDepartment != '')
{
cnt++;
cont2 += ['Department',mDepartment];
}
if(mCustomerGroup != '')
{
cnt++;
cont2 += ['CustomerGroup',mCustomerGroup];
}
if(mBusinessUnit != '')
{
cnt++;
cont2 += ['BusinessUnit',mBusinessUnit];
}
if(mLocationType != '')
{
cnt++;
cont2 += ['LocationType',mLocationType];
}
if(mCompetency != '')
{
cnt++;
cont2 += ['Competency',mCompetency];
}
if(mProject != '')
{
cnt++;
cont2 += ['Project',mProject];
}
if(mRegion != '')
{
cnt++;
cont2 += ['Region',mRegion];
}
if(mWorker != '')
{
cnt++;
cont2 += ['Worker',mWorker];
}
if(ledgerJournalTrans.AccountType == LedgerJournalACType::Ledger)
{
cont1 += ['MainAccount',AccountNumb,cnt];
cont1 += cont2;
ledgerDim = AxdDimensionUtil::getLedgerAccountId(cont1);
if(ledgerDim == 0)
{
offSetAcctPattern = [AccountNumb,AccountNumb];
ledgerDim = AxdDimensionUtil::getLedgerAccountId( offSetAcctPattern);
}
ledgerJournalTrans.LedgerDimension = ledgerDim;
}
else
{
ledgerDim = DimensionStorage::getDynamicAccount(AccountNumb,ledgerJournalTrans.AccountType);
ledgerDimension += cnt;
ledgerDimension += cont2;
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
ledgerJournalTrans.LedgerDimension = ledgerDim;
LedgerJournalTrans.modifiedField(fieldNum(LedgerJournalTrans,LedgerDimension));
ledgerJournalTrans.DefaultDimension = DimensionDefault;
13 July 2016
24 June 2016
X++ code to generate ledger voucher number sequence in AX 2012
NumberSeq numberSeq;
NumberSequenceTable numSeqTable;
Voucher voucher;
select firstOnly numSeqTable
where numSeqTable.RecId == LedgerJournalName::find(ledgerJournalTable.JournalName).NumberSequenceTable;
if (numSeqTable && !voucher)
{
numberseq = numberseq::newGetVoucherFromCode(numSeqTable.NumberSequence);
voucher = numberseq.voucher();
}
ledgerJournalTrans.Voucher = voucher;
21 June 2016
Subscribe to:
Posts (Atom)
Service class to get the selected record and deleted matching records and refresh the form data source in D365 F&O
[DataContractAttribute] class ABCUserProfilesBulkDeleteContract { UserId userId; [DataMemberAttribute('UserId')] pu...
-
Please click here to access Custom Workflow step by step process:
-
public InventQty onHandInventory(ItemId itemId, InventSiteId inventSiteId,InventLocationId inventLocation) { InventOnhand inventOnh...
-
1. In classDeclaration extend SrsReportDataProviderPreProcess instead of SrsReportDataProviderBase 2. Temp table properties should b...


