example code to fix it :
hcmEmploymentEmployee.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
example code
public static DimensionDynamicAccount defaultDimension2ledgerDimension(LedgerJournalAC _ledgerJournalAC,DimensionDefault _defaultDimension ) { container conDimName; container conDimValue; int loop = 1; DimensionValue dimValue; Name dimName; DimensionServiceProvider DimensionServiceProvider = new DimensionServiceProvider(); LedgerAccountContract LedgerAccountContract = new LedgerAccountContract(); List ListValueContract = new List(Types::Class); DimensionAttributeValueContract ValueContract; dimensionAttributeValueCombination dimensionAttributeValueCombination; DimensionStorage dimStorage; conDimName = Global::getDimensionNameTID(); while(loop <= conLen(conDimName)) { dimName = conPeek(conDimName,loop); dimValue = Global::getDimensionValueTEC(_defaultDimension,dimName); if(dimValue) { ValueContract = new DimensionAttributeValueContract(); ValueContract.parmName(dimName); ValueContract.parmValue(dimValue); ListValueContract.addEnd(ValueContract); } loop++; } LedgerAccountContract.parmMainAccount(_ledgerJournalAC); LedgerAccountContract.parmValues(ListValueContract); dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract); dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save()); return dimensionAttributeValueCombination.RecId; }
this below is a custom method on global class.. (or you can put it on other class)
public static container getDimensionNameTID() { DimensionAttribute dimAttr; DimensionAttributeSetItem dimAttrSetItem; DimensionEnumeration dimensionSetId; DimensionAttributeValue dimAttributeValue; container DimensionName; dimensionSetId = DimensionCache::getDimensionAttributeSetForLedger(); while select dimAttr order by Name where dimAttr.Type != DimensionAttributeType::MainAccount join RecId from dimAttrSetItem where dimAttrSetItem.DimensionAttribute == dimAttr.RecId && dimAttrSetItem.DimensionAttributeSet == dimensionSetId { dimensionName += dimAttr.Name; } return DimensionName; }
this below is a custom method on global class.. (or you can put it on other class)
public static str 255 getDimensionValueTEC(RecId defaultDimension, Name dimName) { DimensionAttributeValueSetStorage dimStorage; Counter i; DimensionAttribute dimAttributeCostCenter; DimensionAttributeValue dimAttributeValue; dimStorage = DimensionAttributeValueSetStorage::find(defaultDimension); return dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName(dimName).RecId); }
example code :
public static void autoSettlementJournalFromPAYDetails(JournalId _journalNum) { CustVendOpenTransManager manager; CustTrans custTrans; CustTransOpen custTransOpen; LedgerJournalTrans ledgerJournalTrans; AxLedgerJournalTable axLedgerJournalTable; AxLedgerJournalTrans axLedgerJournalTrans; ExchangeRateHelper exchangeRateHelper; AmountCur totalSettleAmount; AmountCur amountCurDebit,amountCurCredit; HRSPayJournalDetails hrsPayJournalDetails; HRSPayJournalTable hrsPayJournalTable; int Row; AxLedgerJournalTable = AxLedgerJournalTable::newLedgerJournalTable(LedgerJournalTable::find(_journalNum)); ttsBegin; //details journal lines from Pay Journal Details while select hrsPayJournalTable join hrsPayJournalDetails where hrsPayJournalTable.HRSPayJournalId == hrsPayJournalDetails.HRSPayJournalId && HRSPayJournalTable.JournalNum == _journalNum { CustTrans = CustTrans::findFromInvoice(hrsPayJournalDetails.ReferenceNumber,HRSPayJournalDetails.AccountNum); CustTransOpen = CustTransOpen::findRefId(CustTrans.RecId); if(CustTransOpen) { //Create Trans ... axLedgerJournalTrans = new axLedgerJournalTrans(); axLedgerJournalTrans.parmJournalNum(AxLedgerJournalTable.ledgerJournalTable().JournalNum); axLedgerJournalTrans.parmTransDate(today()); axLedgerJournalTrans.parmDue(today()); axLedgerJournalTrans.parmAccountType(LedgerJournalACType::Cust); axLedgerJournalTrans.parmLedgerDimension(DimensionStorage::getDynamicAccount(hrsPayJournalDetails.AccountNum, LedgerJournalACType::Cust)); axLedgerJournalTrans.parmAmountCurCredit(hrsPayJournalDetails.Credit); axLedgerJournalTrans.parmAmountCurDebit(hrsPayJournalDetails.Debit); axLedgerJournalTrans.save(); manager = CustVendOpenTransManager::construct(axLedgerJournalTrans.ledgerJournalTrans()); manager.updateTransMarked(custTransOpen,true); if(hrsPayJournalDetails.Debit) { manager.updateSettleAmount(custTransOpen,hrsPayJournalDetails.Debit); } else { manager.updateSettleAmount(custTransOpen,hrsPayJournalDetails.Credit); } //update after settle ledgerJournalTrans = axLedgerJournalTrans.ledgerJournalTrans(); ledgerJournalTrans.selectForUpdate(true); ledgerJournalTrans.SettleVoucher = SettlementType::SelectedTransact; ledgerJournalTrans.update(); Row++; } } ttsCommit; info(strFmt("Total Lines settled : %1",Row)); }
it is common for user to search item based on name. but currently on AX 2012, onHand form can’t provide search based on item name or search name. It will take a little modification from technical side.
example how to do it :
1. you can join directly on form datasource or create view like example (i’m using the view that already created for another purpose)
2. on InventSumTable add relations like this.
3. then go to form onHand (InventOnHandItem), and add the view to datasource
4. open class InventDimCtrl_Frm_OnHand and modify method modifyQuery , on class declaration parameter, add new parameter FormDataSource with default null parameter. then define new variable QueryBuildDataSource.
5. on the last line of the method modifyQuery , add code like example :
if(_tidInventLookUp) { qbsInventLookup = query.dataSourceName(_tidInventLookUp.name()); //filter current company language qbr = SysQuery::findOrCreateRange(qbsInventLookup, fieldnum(TIDInventLookup, LanguageId)); qbr.value(queryValue(CompanyInfo::languageId())); qbsInventLookup.addGroupByField(fieldNum(TIDInventLookup,Name)); qbsInventLookup.addGroupByField(fieldNum(TIDInventLookup,NameAlias)); }
5. then back to the form, on datasource inventSUm, on executeQuery , modify the code from
void executeQuery() { element.inventDimSetupObject().modifyQuery(inventSum_DS,inventDim_DS); super(); }
to
void executeQuery() { element.inventDimSetupObject().modifyQuery(inventSum_DS,inventDim_DS,TIDInventLookUp_ds); super(); }
6. drag the field from newly add datasource on form to the grid :
7. Voila done, example result, :
note: remember to GROUPBY on code if you add new field to the form, or the field on form will show “UNRETRIEVED”
public void initializeQuery(Query _query) { // ListPageLabelChange => Common externalRecord; FormDataSource frmDs; FormRun formRun; FormControl frmCtrl; // ListPageLabelChange <= _query.dataSourceTable(tableNum(HRSBenefitEntitlement)).addRange(fieldNum(HRSBenefitEntitlement,Employment)).value(SysQuery::value(HcmEmployment::findByWorkerLegalEntity(HcmWorker::userId2Worker(curUserId()),CompanyInfo::find().RecId).RecId)); super(_query); // ListPageLabelChange => externalRecord = this.listPage().activeRecord(_query.dataSourceTable(tableNum(HRSBenefitEntitlement)).name());//No intrisic function for form DS? if(externalRecord.isFormDataSource()) { frmDs = externalRecord.dataSource(); formRun = frmDs.formRun(); if(formRun) { frmCtrl = formRun.design().controlName(formControlStr(TIDBenefitEntitlementListPage,HRSBenefitEntitlement_Entitlement)); if(frmCtrl) { frmCtrl.userPromptText("newName"); } } } // ListPageLabelChange <= }
clear usage data if no changes on form.