The task is to set range for finacial dimension .
Issue:
1. Get all the users who are assigned to particular deparment dimension value
2. To set range for Dimension ( department).
========================================================================
Explanation :
1. dimAttributeDep = DimensionAttribute::getAttributeByUnitType(DimensionUnitType::Department);
The above command gets "Department" in to string "dimAttributeDep"
2. SysQuery::addDimensionAttributeRange(_query,
queryDataSourceStr(PurchTableListPage,
PurchaseTable),
fieldId2name(tableNum(PurchTable), fieldnum(PurchTable, DefaultDimension)),
DimensionComponent::DimensionAttribute,
filterDep,
dimAttributeDep.Name);
The above command Sets range for "Department" in financial Dimension . where filterDep holds the range value ( example 101 - for dimension Department.
3. departmentRecIds =
HcmWorker::getDepartmentRecIds(SysQueryRangeUtil::currentWorkerRecId());
for
(i=1;i<=conLen(departmentRecIds);i++)
// Code for this method is given in below table
{
OMOperatingUnit::numberOfWorkers(true, true,
conPeek(departmentRecIds,i),DateTimeUtil::utcNow(),setWorkers);
}
if
(setWorkers.elements() > 0)
{
setIterator = new SetIterator(setWorkers);
setIterator.begin();
while (setIterator.more())
{
strWorkers += strFmt("%1,",setIterator.value());
}
The above code gets the Workers assigned to particular Department - '101' for department For example.
================================================================================================================
public void
initializeQuery(Query _query)
{
worker =
HcmWorker::find(SysQueryRangeUtil::currentWorkerRecId());
if
(!worker)
throw error(strfmt('%1%2', CurUserId(),' has not been linked to any employee record.\nPlease
contact you system administrator to rectify the problem.' ));
filterDep =
DirPerson::find(worker.Person).Filter; // filterDep
– is assigned value and Range is applied for Department without any check of
Filter we applied in front end
if(filterDep)
{
dimAttributeDep = DimensionAttribute::getAttributeByUnitType(DimensionUnitType::Department);
SysQuery::addDimensionAttributeRange(_query,
queryDataSourceStr(PurchTableListPage,
PurchaseTable),
fieldId2name(tableNum(PurchTable), fieldnum(PurchTable, DefaultDimension)),
DimensionComponent::DimensionAttribute,
filterDep,
dimAttributeDep.Name);
}
-----------------------------------------------------------------------------------------------------------------
if (filterCreator == NoYes::Yes)
{
if
(filterUseHome)
{
departmentRecIds = HcmWorker::getDepartmentRecIds(SysQueryRangeUtil::currentWorkerRecId());
for (i=1;i<=conLen(departmentRecIds);i++) // Code for this method is given in below table
{
OMOperatingUnit::numberOfWorkers(true, true, conPeek(departmentRecIds,i),DateTimeUtil::utcNow(),setWorkers);
}
if (setWorkers.elements() > 0)
{
setIterator = new SetIterator(setWorkers);
setIterator.begin();
while (setIterator.more())
{
strWorkers +=
strFmt("%1,",setIterator.value());// Apply
range – for Worker Condition – 3 (If it doesn’t get in to this loop ,
strWorkers = “”) . This is what happening for condition 3 .. it is not moving
in to this loop due to data and range
.
value
for Worker is “”
setIterator.next();
}
}
}
else
{
strWorkers = SysQuery::value(SysQueryRangeUtil::currentWorker());
}
rangeWorker.value(strWorkers); // Apply range – for
Worker Condition – 1 ( Current Worker)
if(filterDep)
{
SysQuery::clearDimensionRangesFromQuery(_query);
}
}
Else //
Moves to this code if (filterCreator = NoYes::No)
{
rangeWorker.value(SysQuery::valueUnlimited());// Apply range – for Worker
Condition – 2 ( All workers)
if(filterDep)
{
SysQuery::addDimensionAttributeRange(_query,
queryDataSourceStr(PurchTableListPage, PurchaseTable),
fieldId2name(tableNum(PurchTable), fieldnum(PurchTable, DefaultDimension)),
DimensionComponent::DimensionAttribute,
filterDep,
dimAttributeDep.Name);
}
}
public static container
getDepartmentRecIds(HcmWorkerRecId _workerRecId, utcdatetime _asOfDate =
DateTimeUtil::utcNow())
{
#HRMConstants
HcmPositionWorkerAssignment
positionWorkerAssignment;
HcmPositionDetail
positionDetail;
HcmPositionDuration
positionDuration;
----
----
while select ValidTimeState(_asOfDate) Department from
positionDetail
exists join positionWorkerAssignment
where positionWorkerAssignment.Position == positionDetail.Position &&
positionWorkerAssignment.Worker == _workerRecId
exists join positionDuration
where positionDuration.Position == positionDetail.Position
{
result =
conIns(result, conLen(result) + 1, positionDetail.Department);
}
}
No comments:
Post a Comment