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

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
What is the _isMexican boolean for in the Global::Checkpower method?
AlwaysOnTop property not behaving properly
Boolean AND logic in Microsoft Dynamics AX 2012 AIF QueryCriteria
Table: PrintMgmtSettings Field: Printjobsettings(Blob)
What happened to the hrplimittablerelationship table in ax-2012-r2?
Why is my changes ignored to releaseupdate scripts in dynamics ax 2012 r2
What is “old sys” exactly and why would I receive errors in 2012 because of a missing Macro?
How to filter records in line grid based on selected record in header grid?

Categories

HOME
beautifulsoup
codenvy
rsa
socket.io
graphics
alarm
polling
vsm
crystal-reports-2013
azure-container-service
pkcs#11
mql5
octave
mautic
automatic-ref-counting
supervisor
favicon
scrolltop
flatpak
azure-powershell
alpacajs
scsi
symfony-2.8
atlassian-stash
chargify
dreamweaver
jmp
imagemap
backpack-for-laravel
ios10.2
object-storage
highstock
dynamically-generated
jquery-multiselect
shared
ms-access-web-app
delimiter
angular-translate
sinch
dst
zend-debugger
cognos-bi
git-squash
hreflang
sendbird
hibernate-search
cd
release
azure-arm
levenshtein-distance
skylink
apriori
wc
strftime
hammer.js
rserve
tf
scalding
dt
mouseleave
template-toolkit
google-photos
pocketsphinx-android
change-tracking
cudd
redistributable
lrs
watch-os-2
drawstring
jclouds
fink
beanstalk
jaunt-api
sapi
assertion
gocql
themoviedb-api
rewrite
toolkit
teamcity-9.1
git-ftp
bufferedinputstream
cross-join
post-commit-hook
teaspoon
functional-java
menubar
ora-06550
light
inputmismatchexception
ebay-lms
cmmi
octal
resource-management
correlated-subquery
inkcanvas
jsr286
urlrewriter
entity-attribute-value
pylucene
multiplatform
luajava
cfwindow
django-piston
wysiwym
perl5.12
linfu-dynamicproxy

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App