I am Writing the Code in DP Class to split the Ledger account and display individually..
But i am Unable to get the Worker name
dimensionFocus = 14240301-00000002-00000021-100020;
worker = subStr(dimensionFocus,33,7);
select PersonnelNumber from hcmWorker
where hcmWorker.PersonnelNumber == worker;
workerName = hcmWorker.name();
In this Worker is Showing, i am not getting worker name.
I am Writing this code in Job it is working, in class it is Not Working...
*This post is locked for comments
Hi Srinivas,
I'm losing you now. You didn't mention 'budgettmpbalance' before in your question. Is this related to this question? tmp means temporary, so there isn't a related, I guess. How the temporary table is built up, depends on settings and usage of the AX environment. So this also determines if in some point of time the values in the budgettmpbalance and generaljournalaccountentry are the same or not.
Yes I am Totally agree with you..
but why this budgettmpbalance.dimensionfocus is not equal to the generaljournalaccountentry.ledgeraccount
how to find out a realtion?
how to get the ledgerdimension based on the Budgettmpbalance.dimensionfocus in RDP class?
Hi Srinivas,
You are using the LedgerAccount field which indeed is a string field. Note that within a legal entity different accounts can have another number of dimensions or no dimension. Also the order can be different.
The field LedgerDimension is having a record ID reference which can be used in the coding example provided in the blog.
If you have Worker ID (Personnel Number), then :
HcmWorker::findByPersonnelNumber(worker).name;
If you have Worker RecID , then :
HcmWorker::find(workerRecid).name();
Hi Andre,
First i am try this above scenario, but i am unable to pass the Current dimension focus in to general journal account entry table Ledger account..
That's why i am choose this way..
Please check my code..
In this i am unable to find out a realtion for generaljournalAccountEntry and dimension focus of the budget tmp balance table
select generalJournalAccountEntry
where generalJournalAccountEntry.LedgerAccount == this.DimensionFocus;//"2221100-00000021-00000101-00000027";
//Fetch the Value combination record
dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(generalJournalAccountEntry.LedgerDimension);
// Get dimension storage
dimensionStorage = DimensionStorage::findById(generalJournalAccountEntry.LedgerDimension);
if (dimensionStorage == null)
{
throw error("@SYS83964");
}
// Get hierarchy count
hierarchyCount = dimensionStorage.hierarchyCount();
//Loop through hierarchies to get individual segments
for(hierarchyIndex = 1; hierarchyIndex <= hierarchyCount; hierarchyIndex++)
{
//Get segment count for hierarchy
segmentCount = dimensionStorage.segmentCountForHierarchy(hierarchyIndex);
//Loop through segments and display required values
for (segmentIndex = 1; segmentIndex <= segmentCount; segmentIndex++)
{
// Get segment
segment = dimensionStorage.getSegmentForHierarchy(hierarchyIndex, segmentIndex);
// Get the segment information
if (segment.parmDimensionAttributeValueId() != 0)
{
// Get segment name
segmentName = DimensionAttribute::find(DimensionAttributeValue::find(segment.parmDimensionAttributeValueId()).DimensionAttribute).Name;
//Get segment value (id of the dimension)
segmentValue = segment.parmDisplayValue();
//Get segment value name (Description for dimension)
if(segmentName == 'MainAccount')
{
MainAccountDescription = segment.getName();
}
if(segmentName == 'BusinessUnit')
{
BusinessUnitDescription = segment.getName();
}
if(segmentName == 'Zone')
{
ZoneDescription = segment.getName();
}
if(segmentName == 'Department')
{
DepartmentDescription = segment.getName();
}
this.SG_Name = MainAccountDescription + ' -' + BusinessUnitDescription + ' -' + ZoneDescription + ' -' + DepartmentDescription;
}
}
}
Hi Srinivas,
It would be more safe to use the DimensionStorage and DimensionStorageSegment classes to retrieve the personnel number. If the length of one of the dimensions will be different in another environment it isn't working with the hardcoded subStr command. Have a look at the next blog how to use this: sumitsaxfactor.wordpress.com/.../getting-individual-dimension-combination-valuesdimension-storage-class-ax-2012
Please note that the replacement of the select field list is also an important change, since you are using in the name method other fields from the buffer and you need to load them.
Now it is working..
after changing these..
worker = subStr(dimensionFocus,34,7);
HI Iulian Cordobin,
I am Removing the Caches and Remove the Usage, still it is not working..
is there is any other way to get the worker name from worker id?
I assume you made the code change. After this, since it is a DP class, perform a full refresh of the caches (from the Development workspace -> Tools -> Caches / all 4 entries).
André Arnaud de Cal...
292,031
Super User 2025 Season 1
Martin Dráb
230,868
Most Valuable Professional
nmaenpaa
101,156