x++


Getting the index of an array element of EDT Dimension


I need to write a job where i could fetch the index of an array element of EDT Dimension
e.g. In my EDT Dimension i have array elements A B C when i click over them for properties I see the index for A as 1, B as 2 and C as 3. Now with a job ui want to fetch the index value. Kindly Assist.
I'm not sure if I did understand the real problem. Some code sample could help.
The Dimensions Table has some useful methods like arrayIdx2Code.
Maybe the following code helps:
static void Job1(Args _args)
{
Counter idx;
Dimension dimension;
DimensionCode dimensionCode;
str name;
;
for (idx = 1; idx <= dimof(dimension); idx++)
{
dimensionCode = Dimensions::arrayIdx2Code(idx);
name = enum2str(dimensionCode);
// if (name == 'B') ...
info(strfmt("%1: %2", idx, name));
}
}
I found a way but still looking if there is any other solution.
static void Job10(Args _args)
{
Dicttype dicttype;
counter i;
str test;
;
test = "Client";
dicttype = new dicttype(132);//132 here is the id of edt dimension
for (i=1;i<=dicttype.arraySize();i++)
{
if ( dicttype.label(i) == test)
{
break;
}
}
print i;
pause;
}
Array elements A B C from your example are nothing else but simple labels - they cannot be used as identifiers. First of all, for user convenience the labels can be modified anytime, then even if they aren't, the labels are different in different languages, and so on and so forth.
Overall your approach (querying DictType) would be correct but I cannot think of any scenario that would actually require such a code.
If you clarified your business requirements someone could come up with a better solution.

Related Links

Extend system menu in Dynamics AX 2012?
How to show selected items of certain table on the different table in Dynamics AX 2012?
AllowEdit doesn't work properly in Dynamics AX
AX 2012 how to set args record datasource in X++
Clients seem to be running old (buggy) code after XPO project import
Number sequence AX 2012
SSRS MS words report with page break
How can you get a detailed error descriptions in Dynamics AX?
How to get the length of an array?
X++ loop through lines in grid control
Concatenating row values in x++
How do you access a macro in the AOT macro node?
How can I set the Backgoundcolor of an AX2012 Action Pane Button
How to Edit address using X++ in AX 2012
Number sequence issue Ax 2012?
Find code that's running in a Batch Job

Categories

HOME
google-app-engine
phpword
microsoftgraph
telegram
android-studio-2.2
pda
interface
themes
package
solver
r-googlesheets
rendering
newrelic
big-o
gluon-mobile
lanczos
barcode
minecraft-forge
project-intu
cmdb
angular-dart
speech-synthesis
symmetricds
capistrano3
bourbon
monit
ckfinder
data.stackexchange.com
opentk
jquery-multiselect
bulletphysics
exchangewebservices
uitapgesturerecognizer
nsurl
paragraph
mockjax
clickjacking
code-snippets
android-maps-extensions
reactjs.net
fiware-cygnus
video-capture
xajax
python-pptx
latitude-longitude
flatmap
hackintosh
signals-slots
vmware-fusion
apriori
congestion-control
tcc
xmldocument
flask-login
vaadin-elements
automapper-5
openrasta
jquery-ui-draggable
facebook-pixel
datamaps
x-ray
css-transforms
baidu
rmongo
uicolor
i386
qiime
omniauth-facebook
spreadjs
false-sharing
relativelayout
boomerang
themoviedb-api
vigenere
extjs-grid
zscript
dulwich
xmltype
phpldapadmin
boost-program-options
addressing-mode
psr-4
ora-00904
android-framework
scriptaculous
mt4j
jquery-1.9
saleslogix
faye
inkcanvas
usertype
hibernateexception
android-holo-everywhere
mbeans
cgbitmapcontextcreate
undefined-index
web-garden
build-environment
cuda.net
sifr3
fdf
wcf-proxy

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App