static void Explorer_UpdateProjDim(Args _args)
{
container readCon;
Dialog dialog;
DialogField dialogField;
FileName fileName;
Struct struct;
ProjId projId;
ProjTable projTable;
container ledgerDimension;
CommaTextIO commaIO;
int i, records;
#File
#file
dialog = new Dialog ("Select Project Master CSV File");
dialogField = dialog.addField(extendedTypeStr(FilenameOpen));
dialog.filenameLookupFilter(['*.CSV']);
if (dialog.run())
{
fileName = dialogField.value();
if(!filename)
{
throw error('Filename must be filled');
}
}
commaIO = new CommaTextIo(fileName, 'r');
commaIO.inFieldDelimiter(',');
readCon = commaIO.read();
if (commaIO)
{
ttsBegin;
while (commaIO.status() == IO_Status::ok)
{
readCon = commaIO.read();
if (readCon)
{
projId = conPeek(readCon, 1);
struct = new Struct();
struct.add('Brand', conPeek(readCon, 2)); // specify dimensions
struct.add('Client', conPeek(readCon, 3)); // specify dimensions
struct.add('MasterClient', conPeek(readCon, 4)); // specify dimensions
struct.add('Product', conPeek(readCon, 5)); // specify dimensions
ledgerDimension = conNull();
ledgerDimension += struct.fields();
for (i = 1; i <= struct.fields(); i++)
{
ledgerDimension += struct.fieldName(i);
ledgerDimension += struct.valueIndex(i);
}
projTable = projTable::find(projId, true);
if(projTable)
{
projTable.DefaultDimension = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
if(projTable.validateWrite())
{
projTable.update();
records++;
}
}
else
{
error(strFmt("Projid:%1 not exists", projId));
}
}
}
ttsCommit;
}
info(strFmt("%1 records Updated", records));
}
Showing posts with label Dimentions. Show all posts
Showing posts with label Dimentions. Show all posts
3 Dec 2018
7 Jan 2017
Get Mainaccount from ledgerDimension through X++ in AX 2012
public void Mainaccount(LedgerDimensionDefaultAccount _LedgerDimensionDefaultAccount)
{
DimensionAttributeValueCombination combination;
MainAccount mainAccount;
;
select DisplayValue from combination
where combination.recId == _LedgerDimensionDefaultAccount;
select * from mainAccount where mainAccount.RecId == combination.MainAccount;
Return mainAccount.MainAccountId;
}
{
DimensionAttributeValueCombination combination;
MainAccount mainAccount;
;
select DisplayValue from combination
where combination.recId == _LedgerDimensionDefaultAccount;
select * from mainAccount where mainAccount.RecId == combination.MainAccount;
Return mainAccount.MainAccountId;
}
4 Aug 2016
Check Employee dimension through code + AX 2012
Hi Folks,
Recently my client face problem with Employee dimension.
Issue::
My client doing some functionality for that employee required some mandatory dimensions( Branch , Segment, Projects, BusinessUnits) but some employees don't have dimensions.
There are almost 2000 employees, it's not a easy task to check every employee for dimensions,
For that he asked me write a job for who don't have particular dimensions ( Branch , Segment, Projects, BusinessUnits).
Solution::
static void ExplorerGetdefaultdim(Args _args)
{
HcmEmployment hcmEmployment,hcmEmploymentloc;
str id;
str res;
boolean checkproj= true;
boolean checkbranch= true;
boolean checksegme= true;
boolean checkbussunit = true;
DimensionAttributeValueSetStorage dimStorage;
Counter i;
while select * from hcmEmployment where hcmEmployment.DefaultDimension != 0
// some employees don't have any dimensions i m not bothering about who don't have any //dimensions
{
select hcmEmploymentloc order by hcmEmploymentloc.RecId desc where hcmEmploymentloc.Worker == hcmEmployment.Worker;
checkbranch= true;
checksegme= true;
checkbussunit = true;
dimStorage = DimensionAttributeValueSetStorage::find(hcmEmploymentloc.DefaultDimension);
checkproj= true;
for (i=1 ; i<= dimStorage.elements() ; i++)
{
//info(strFmt("Worker :%1,Dimension :%2,Value :%3",hcmEmployment.Worker,DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name +"----" +dimStorage.getDisplayValueByIndex(i))); // if u want to see employee all dimensions
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Branch")
{
checkbranch = false;
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Segment")
{
checksegme =false;
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Projects")
{
checkproj =false;
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "BusinessUnits")
{
checkbussunit = false;
}
}
if(checkbussunit == true ||checkproj == true|| checkbranch == true ||checksegme == true)
{
info(strFmt("Errors result %1",HcmWorker::find(hcmEmployment.Worker).name()));
}
}
}
Recently my client face problem with Employee dimension.
Issue::
My client doing some functionality for that employee required some mandatory dimensions( Branch , Segment, Projects, BusinessUnits) but some employees don't have dimensions.
There are almost 2000 employees, it's not a easy task to check every employee for dimensions,
For that he asked me write a job for who don't have particular dimensions ( Branch , Segment, Projects, BusinessUnits).
Solution::
static void ExplorerGetdefaultdim(Args _args)
{
HcmEmployment hcmEmployment,hcmEmploymentloc;
str id;
str res;
boolean checkproj= true;
boolean checkbranch= true;
boolean checksegme= true;
boolean checkbussunit = true;
DimensionAttributeValueSetStorage dimStorage;
Counter i;
while select * from hcmEmployment where hcmEmployment.DefaultDimension != 0
// some employees don't have any dimensions i m not bothering about who don't have any //dimensions
{
select hcmEmploymentloc order by hcmEmploymentloc.RecId desc where hcmEmploymentloc.Worker == hcmEmployment.Worker;
checkbranch= true;
checksegme= true;
checkbussunit = true;
dimStorage = DimensionAttributeValueSetStorage::find(hcmEmploymentloc.DefaultDimension);
checkproj= true;
for (i=1 ; i<= dimStorage.elements() ; i++)
{
//info(strFmt("Worker :%1,Dimension :%2,Value :%3",hcmEmployment.Worker,DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name +"----" +dimStorage.getDisplayValueByIndex(i))); // if u want to see employee all dimensions
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Branch")
{
checkbranch = false;
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Segment")
{
checksegme =false;
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Projects")
{
checkproj =false;
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "BusinessUnits")
{
checkbussunit = false;
}
}
if(checkbussunit == true ||checkproj == true|| checkbranch == true ||checksegme == true)
{
info(strFmt("Errors result %1",HcmWorker::find(hcmEmployment.Worker).name()));
}
}
}
29 Jun 2016
Get Individual dimensions from default dimensions + ax 2012
HI All,
Recently i got requirement like display Individual dimensions from default dimensions in purchase order.
These Individual dimensions i need to show in SSRS report.
protected Description GetDefaultDimensionAttributeName(DimensionDefault _dimensionDefault)
{
DimensionAttributeValueSetStorage dimStorage;
DimensionDefault HcmPositionDefaultDimension;
DimensionAttribute DimensionAttribute;
Counter i;
DimensionAttribute dimAttr;
DimensionAttributeValue dimAttrValue;
Common common;
DictTable dictTable;
str Name,Namecmp;
str value;
// make the dimension storage object
dimStorage = DimensionAttributeValueSetStorage::find(_dimensionDefault);
for (i=1 ; i<= dimStorage.elements() ; i++)
{
// get attribute select here.
select firstonly dimAttrValue
where dimAttrValue.RecId == dimStorage.getValueByIndex(i)
join dimAttr
where dimAttr.RecId == dimAttrValue.DimensionAttribute;
if (dimAttr && dimAttrValue)
{
dictTable = new DictTable(dimAttr.BackingEntityType);
common = dictTable.makeRecord();
if (common.TableId)
{
select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;
Namecmp = dimAttr.Name;
//My requirement like i want only BusinessUnit dimensions
if(Namecmp like "BusinessUnit")
{
name = common.(dimAttr.NameAttribute); //Dimension Description
value = common.(dimAttr.ValueAttribute); //Dimension Value
}
}
}
}
return name;
}
Recently i got requirement like display Individual dimensions from default dimensions in purchase order.
These Individual dimensions i need to show in SSRS report.
protected Description GetDefaultDimensionAttributeName(DimensionDefault _dimensionDefault)
{
DimensionAttributeValueSetStorage dimStorage;
DimensionDefault HcmPositionDefaultDimension;
DimensionAttribute DimensionAttribute;
Counter i;
DimensionAttribute dimAttr;
DimensionAttributeValue dimAttrValue;
Common common;
DictTable dictTable;
str Name,Namecmp;
str value;
// make the dimension storage object
dimStorage = DimensionAttributeValueSetStorage::find(_dimensionDefault);
for (i=1 ; i<= dimStorage.elements() ; i++)
{
// get attribute select here.
select firstonly dimAttrValue
where dimAttrValue.RecId == dimStorage.getValueByIndex(i)
join dimAttr
where dimAttr.RecId == dimAttrValue.DimensionAttribute;
if (dimAttr && dimAttrValue)
{
dictTable = new DictTable(dimAttr.BackingEntityType);
common = dictTable.makeRecord();
if (common.TableId)
{
select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;
Namecmp = dimAttr.Name;
//My requirement like i want only BusinessUnit dimensions
if(Namecmp like "BusinessUnit")
{
name = common.(dimAttr.NameAttribute); //Dimension Description
value = common.(dimAttr.ValueAttribute); //Dimension Value
}
}
}
}
return name;
}
18 May 2015
Creating Ledger Dimension Using a segmented entry control + ax 2012
- Segmented entry control can simplify the task of entering complex main account and dimension combinations.
- The control consists of a dynamic number of elements named segments. The number of segments may vary, depending on the setup, and their lookup values may be dependent on the values specified in other segments in the same control.
- The segmented entry control always uses the controller class, which handles the entry and display in the control.
Example
- LedgerParameters table and create a new field with the following properties (click on Yes to automatically add a foreign key relation once asked):
- Find the table's relation named DimensionAttributeValueCombination, and change its property as follows:
- In LedgerParameters form, and add the following code to its classdeclaration():
LedgerDimensionAccountController ledgerDimensionAccountController;
- following code to the bottom of the form's init() method.
- Locate the General_LedgerDimension segmented entry control located in Tab | LedgerTab | LedgerTabBody | LedgerTabFastTab | GeneralTabPage | General, and override methods.
public void loadAutoCompleteData(LoadAutoCompleteDataEventArgs _e)
{
super(_e);
ledgerDimensionAccountController.loadAutoCompleteData(_e);
}
public void loadSegments()
{
super();
ledgerDimensionAccountController.parmControl(this);
ledgerDimensionAccountController.loadSegments();
}
public void segmentValueChanged(SegmentValueChangedEventArgs _e)
{
super(_e);
ledgerDimensionAccountController.segmentValueChanged(_e);
}
On the same form, in its LedgerParameters data source, locate the
LedgerDimension field, and override three of its methods with the following code:
public Common resolveReference(
FormReferenceControl _formReferenceControl)
{
return ledgerDimensionAccountController.resolveReference();
}
public void jumpRef()
{
super();
ledgerDimensionAccountController.jumpRef();
}
public boolean validate()
{
boolean ret;
ret = super();
ret = ledgerDimensionAccountController.validate() && ret;
return ret;
}
Output
4 May 2015
Get Dimensions(Department) in SSRS Report + AX 2012
public Name GetDepartmentName (DimensionDefault _dimension)
{
Name displayName;
DimensionAttributeValueSetItem valueSetItem;
DimensionAttribute dimAttribute;
DimensionAttributeValue dimAttributeValue;
//CustInvoiceLine _custInvoiceLine;
//CustInvoiceTable CustInvoiceTable;
select DimensionAttributeValueSet from valueSetItem
where valueSetItem.DimensionAttributeValueSet == _dimension
join RecId from dimAttributeValue
where valueSetItem.DimensionAttributeValue == dimAttributeValue.RecId
join RecId from dimAttribute
where dimAttributeValue.DimensionAttribute == dimAttribute.RecId
&& dimAttribute.Name == enum2str(sysdimension::Department);
displayName = DimensionAttributeValue::find(dimAttributeValue.RecId).getName();
return displayName;
}
{
Name displayName;
DimensionAttributeValueSetItem valueSetItem;
DimensionAttribute dimAttribute;
DimensionAttributeValue dimAttributeValue;
//CustInvoiceLine _custInvoiceLine;
//CustInvoiceTable CustInvoiceTable;
select DimensionAttributeValueSet from valueSetItem
where valueSetItem.DimensionAttributeValueSet == _dimension
join RecId from dimAttributeValue
where valueSetItem.DimensionAttributeValue == dimAttributeValue.RecId
join RecId from dimAttribute
where dimAttributeValue.DimensionAttribute == dimAttribute.RecId
&& dimAttribute.Name == enum2str(sysdimension::Department);
displayName = DimensionAttributeValue::find(dimAttributeValue.RecId).getName();
return displayName;
}
13 Aug 2013
Fix for adding a new dimension in Dynamics AX
A very minor fix is required on the following SysDimensionAddWizard class to enhance the dimension functionality in Dynamics AX 4.0 and Dynamics AX 2009. This fix is not required for Dynamics AX 2012.
SysDimensionAddWizard class which runs the Financial Dimension Wizard, it is used for adding a new financial dimension to the system. Number of adding dimensions are controlled by Dynamics AX License key. Make sure you have sufficient licenses for the number of dimensions you are adding to Dynamics AX 2009, Since user defined dimensions are limited to seven.
Standard AX comes with the following three default dimensions:
Department
Cost center
Purpose
In SysDimensionAddWizard class changes are required in its run() and versionControlCheckOut() methods.
Add the code to run() method under the if statement as shown in the below image.

Add the code to the versionControlCheckOut() method as shown in the below image.

After adding the above code, test by adding the dimensions.
Note: There's no limitation on creating user defined dimensions, if you are using Dynamics AX 2012 ,the above fix and code changes are not required.
SysDimensionAddWizard class which runs the Financial Dimension Wizard, it is used for adding a new financial dimension to the system. Number of adding dimensions are controlled by Dynamics AX License key. Make sure you have sufficient licenses for the number of dimensions you are adding to Dynamics AX 2009, Since user defined dimensions are limited to seven.
Standard AX comes with the following three default dimensions:
Department
Cost center
Purpose
In SysDimensionAddWizard class changes are required in its run() and versionControlCheckOut() methods.
Add the code to run() method under the if statement as shown in the below image.

Add the code to the versionControlCheckOut() method as shown in the below image.

After adding the above code, test by adding the dimensions.
Note: There's no limitation on creating user defined dimensions, if you are using Dynamics AX 2012 ,the above fix and code changes are not required.
Subscribe to:
Posts (Atom)
Create number sequence in D365 FO
Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...
-
how you can disable a form element, based on the value of another form element. As example, the CustTable form will be used. The examp...
-
Dialogbutton dialogButtonConfirm; ; dialogButtonConfirm = Box::yesNo("continue ", dialogButton::Yes, ...
-
AXAPTA History Axapta 1.0 Development of Axapta began in 1983 at Danish company Damgaard Data A/S. The first version of Axapta (pr...












