x++


Determine if a job is running in X++ code


I have a scenario where a service passes is data to AX, and then we use the SysOperationFramework to process that data without making the service client wait for processing to finish.
An issue arises if the user attempts to open the record in the external application while processing is still occuring.
Is there a way, in X++, so see which jobs are currently executing (and further, see the parameters that were passed in) so that we can send an error that we can handle to the user?
There is a way, yes. The data you are looking for is stored in the Batch table.
You will find a ClassNumber and a Status field. Just select a record matching your class that has the status executing. If a record exists, it is being executed.
The parameters are stored in a the Parameters field in a container. You can unpack the container be creating an instance of your class and unpacking it, like so (quick code that will not compile but you get the point):
Batch batch;
SysOperationServiceController sysOperationServiceController;
YourDataContract yourDataContract;
select batch
where batch.ClassNumber = YourClassNumber
&& batch.Status == BatchStatus::Executing;
// todo: you might have to check the type of the object before assignment
// todo: also check if batch record has been found
sysOperationServiceController = batch.object();
if (sysOperationServiceController.unpack(batch.Parameters))
{
// todo: you might have to check the type of the object before assignment
yourDataContract = sysOperationServiceController.getDataContractObject('_theParemterNameOfyourDataContract');
// todo: here you can read the parameters from your contract
}
else
{
throw error("Unpack failed");
}

Related Links

Adding scrollbar to a Group in AX 2012 form
Table query inconsistent
AX2012 Sales Order Creation through AX Classes
How can I loop over Tables which contain specific characters in their AOT name and delete the data?
Having button that runs code, but doesn't submit data to (or validates against) table
Where are Duties (table name) stored in AX?
Advanced query range
How to read from an Excel file?
group by clause in X++
Determine the number of affected rows by an update_recordset call in Dynamics 4.0?
how to protect the x++ source code
About Data Dictionary
setTimeOut and local function
Passing FromControl in a lookup override method
Reference control from datamethod in generated design
Extended EDT does not compare dates

Categories

HOME
deep-learning
youtube-data-api-v3
mstest
saml-2.0
database-normalization
rom
3d-reconstruction
interpolation
jetty
spring-session
google-cloud-datalab
jax-ws
boto3
joomla3.0
owin
google-chrome-app
github-enterprise
activecollab
x-cart
eip
modbus-tcp
powershell-v5.0
google-container-registry
pyramid
foreign-keys
breadth-first-search
visual-glitch
hta
php-mysqlidb
exploit
qliksense
highstock
licensing
8051
wcag
eviews
database-comparison
r-grid
fstream
hard-drive
installshield-le
joomla2.5
yowsup
mnist
git-rewrite-history
xdocreport
nohup
verifiable-c
diacritics
google-data-api
comparison-operators
tcc
android-checkbox
monkey-testing
httr
puredata
textsum
hammer.js
netbeans6.8
manova
openblas
carrot2
amq
subnet
java-6
microstation
omniauth-facebook
rasterize
eoferror
jdk1.7
wso2greg
mraid
gamekit
grouping-sets
jbake
sip-server
entry-point
psr-4
universal-image-loader
memset
menubar
conditionaltagsupport
light
embedded-fonts
dtmf
oocss
cffile
neos-server
cascadingdropdown
nokia-s40
dajaxice
josql
httponly
fitbounds
stress
pinch
webdev.webserver
codebase
appledoc
updatesourcetrigger
facebook-iframe
drupal-fivestar
rowlex
application-verifier
application-planning
product-management

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