x++


Table query inconsistent


I have a method to retrieve configuration details from a table MyConfiguration. The code currently being used is:
Query query;
QueryRun queryRun;
QueryBuildDataSource qbds;
MyConfiguration config;
int rowCount;
query = new Query();
qbds = query.addDataSource(tableNum(MyConfiguration));
queryRun = new QueryRun(query);
rowCount = SysQuery::countTotal(queryRun);
The table has 0 or 1 rows; there is an if statement of what process to use if there are configuration settings or to use the defaults.
Issue
Although there is a row in the table the query is intermittently returning 0 rows.
Update
Thanks to David's input I have simplified the code:
MyConfiguration config;
select firstOnly useSettings, firstField, secondField from config;
// This wasn't included in the original example, but demonstrates how it's used.
if(config){
// These variables are defined in classDeclaration
useCustom = config.useSettings;
first = config.firstField;
second = config.secondField;
}
else
{
// No custom configuration, use defaults.
useCustom = 0;
}
This code is in a method that is called when the primary method is called to find the configuration to be used.
When I run my test methods in the development environment all the tests pass (the configuration is being read for each test). However when the primary method is called from a button's click event the select isn't returning anything (I've checked this in the debugger). This causes the application to run using the defaults instead of the configured values. If I manually, in the debugger, move the execution past the if the second select also doesn't return any values.
Both the test and the form execute the method in the same way, but are getting different results from the select statement.
Your code looks right.
However the following may be easier to work with and debug
MyConfiguration config;
int rowCount;
;
select firstonly config;
if(config)
{
//Record exists
}
else
{
//Record does not exist
}

Related Links

Extended EDT does not compare dates
How to display a tooltip in Dynamics AX 4.0?
how to disable intellisense in ax2012's code editor?
How do you “Run” a class
General quesions about Dynamics Ax
Convert date into julian date
How to change the level of AX info messages
X++ unbound control
WeekOfYear in X++ using .net lib
How to tell what module has called the program
Getting the index of an array element of EDT Dimension
Destroy Object in X++
not able to run job in batch
Creating a folder on fileSystem dynamics ax
Can the X++ language be used for the following development?
How can you create a simple dialog box in Dynamics AX?

Categories

HOME
gridview
localization
awk
c99
nvd3.js
depth
interface
saml-2.0
composite-primary-key
sitecore
pdfbox
access
entity-framework-core
nsbundle
rom
parameters
nuget-package
webix
performancepoint
qpython
augeas
endpoint
linear-algebra
internationalization
azure-iot-hub
git-extensions
foreign-keys
nim
gmm
sar
simpleitk
href
react-toolbox
draft-js-plugins
definitelytyped
delimiter
soot
tpm
testcomplete
finagle
left-join
kodi
erb
spring-security4
gnat-gps
installshield-le
fossil
diacritics
comparison-operators
branching-and-merging
procfile
snapchat
puredata
pom.xml
ovf
podscms
skin
otp
rsa-archer-grc
docpad
meteor-packages
lrs
adafruit
spring-cloud-feign
observablecollection
swizzling
google-query-language
data-protection
invoke-sqlcmd
piracy-prevention
jnlua
spring-retry
evolus-pencil
telepat
phpldapadmin
exceldatareader
document-repository
theos
android-cookiemanager
sip-server
administration
easyrtc
psr-4
live555
malformedurlexception
wxformbuilder
gnumeric
draw2d-js
vsx
cfcache
koala
syndicationfeed
eclipse-kepler
notorm
process-explorer
facebook-timeline
asplinkbutton
garbage
hibernateexception
fsevents
timthumb
codebase
diagrams
squishit
perl5.12
fdf
great-circle

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