We can get the department name in different ways using default dimension value.
static void DepartmentName(Args _args)
{
DefaultDimensionView defaultDimensionView;
DimAttributeOMDepartment dimAttributeOMDepartment;
//DefaultDimension = 5637151660
select DisplayValue from defaultDimensionView
where defaultDimensionView.DefaultDimension == 5637151660
&& defaultDimensionView.name == 'Department'
join dimAttributeOMDepartment
where dimAttributeOMDepartment.Value == defaultDimensionView.DisplayValue;
info(dimAttributeOMDepartment.Name);
}
static void getDepartmentName(Args _args)
{
str name;
DimensionAttributeValueSetItem valueSetItem;
DimensionAttribute dimAttribute;
DimensionAttributeValue dimAttributeValue;
//Get the Department name for '5637151660' default dimension.
select DimensionAttributeValueSet from valueSetItem
where valueSetItem.DimensionAttributeValueSet == 5637151660
join RecId from dimAttributeValue
where valueSetItem.DimensionAttributeValue == dimAttributeValue.RecId
join RecId from dimAttribute
where dimAttributeValue.DimensionAttribute == dimAttribute.RecId
&& dimAttribute.Name == enum2str(sysdimension::Department);
name = DimensionAttributeValue::find(dimAttributeValue.RecId).getName();
info(name);
}
1st Way: Using Views.
static void DepartmentName(Args _args)
{
DefaultDimensionView defaultDimensionView;
DimAttributeOMDepartment dimAttributeOMDepartment;
//DefaultDimension = 5637151660
select DisplayValue from defaultDimensionView
where defaultDimensionView.DefaultDimension == 5637151660
&& defaultDimensionView.name == 'Department'
join dimAttributeOMDepartment
where dimAttributeOMDepartment.Value == defaultDimensionView.DisplayValue;
info(dimAttributeOMDepartment.Name);
}
2nd Way: Using Tables.
static void getDepartmentName(Args _args)
{
str name;
DimensionAttributeValueSetItem valueSetItem;
DimensionAttribute dimAttribute;
DimensionAttributeValue dimAttributeValue;
//Get the Department name for '5637151660' default dimension.
select DimensionAttributeValueSet from valueSetItem
where valueSetItem.DimensionAttributeValueSet == 5637151660
join RecId from dimAttributeValue
where valueSetItem.DimensionAttributeValue == dimAttributeValue.RecId
join RecId from dimAttribute
where dimAttributeValue.DimensionAttribute == dimAttribute.RecId
&& dimAttribute.Name == enum2str(sysdimension::Department);
name = DimensionAttributeValue::find(dimAttributeValue.RecId).getName();
info(name);
}