insert new budget register entry using x++ coding in ax 2012

Hi All,

Can anyone suggest me how to insert a new budget register entry using x++ coding in ax 2012. Please suggest a solution for this.

Thanks in advance,

Gopinath

Hi All,

using x++ job I wanted to create a new budget transaction entry in ax 2012, Please someone suggest how I can Achieve this. Please do the needful.

Thanks in advance,

Gopinath

Look at the cross references. Example - \Classes\AssetBudgetUpdate\createBudgetTransaction

Hi Kranthi,

while creating new budget transaction using x++ coding by importing field values from excel, I am getting the error - “Cannot insert multiple records in Budget account entries (BudgetTransactionLine). Dimension values: ####### - ###, 25/05/2018.
The record already exists.” because of ledger dimension value in the lines (while inserting multiple lines) . Can You suggest me a solution to solve this error Please.

Thanks in advance,

Gopinath

Are you properly updating the LedgerDimension and BudgetTransactionHeader fields on that table? There is an unique index on these fields including Date.

AxBudgetTransactionHeader budgetTransactionHeader;
AxBudgetTransactionLine budgetTransactionLine;
BudgetTransactionCode budgetTransactionCode;
ReasonTableRef reasonTableRef;
ReasonTable reasonTable;
;
select RecId
from budgetTransactionCode
where budgetTransactionCode.Name == “Adjustment”;

budgetTransactionHeader = new AxBudgetTransactionHeader();
budgetTransactionHeader.parmDate(str2Date(“05-29-2018”,213));
//Given Transaction Number will be replaced by Number Sequences
budgetTransactionHeader.parmTransactionNumber(“Test1”);
budgetTransactionHeader.parmBudgetModelId(“FY2015”);
budgettransactionheader.parmBudgetModelDataAreaId(CompanyInfo::findRecId(CompanyInfo::current()).dataAreaId);
budgetTransactionHeader.parmBudgetTransactionCode(budgetTransactionCode.recid);
budgetTransactionHeader.parmBudgetTransactionType(budgetTransactionCode.BudgetTransactionType);

select ReasonTable where ReasonTable.Reason == “ERROR”;
ReasonTableRef.Reason = ReasonTable.Reason;
ReasonTableRef.ReasonComment = ReasonTable.Description;
ReasonTableRef.insert();
budgetTransactionHeader.parmReasonTableRef(reasonTableref.RecId);
//Creating a Budget Register Entry Header
budgetTransactionHeader.save();

budgetTransactionLine = new AxBudgetTransactionLine();
budgetTransactionLine.parmBudgetTransactionHeader(budgetTransactionHeader::findByTransactionNumber(budgetTransactionHeader.parmTransactionNumber()
,Ledger::current()).RecId);
budgetTransactionLine.parmDate(str2Date(“05-29-2018”,213));
budgetTransactionLine.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId([“MainAccount”,“401200”,4,“BusinessUnit”,“002”,“Department”,“023”,“CostCenter”,“010”,“ItemGroup”,“CarAudio”]));
budgetTransactionLine.parmTransactionCurrencyAmount(15000);
budgetTransactionLine.parmBudgetType(BudgetType::Expense);
budgetTransactionLine.parmTransactionCurrency(“USD”);
//Creating a Budget Register Entry Line
budgetTransactionLine.save();