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

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
What is the _isMexican boolean for in the Global::Checkpower method?

Categories

HOME
go
telegram
nvd3.js
github-for-windows
nunit
angular-formly
pyqt
sh
pclxl
rendering
regular-language
gluon-mobile
pattern-matching
fabric.io
mel
pega
rtf
searchview
google-picker
apache2.4
backpack-for-laravel
aggregation
highstock
comparator
gmock
dapper-extensions
pic32
stackexchange
inversion-of-control
errbot
event-flow
livelink
memory-address
code-snippets
jett
modalviewcontroller
sql-server-ce
watchman
openalpr
amazon-ses
demo
setup.py
plan-9
nanoc
clarifai
sonarlint-eclipse
lightning
amq
qtranslate
java-bytecode-asm
cup
gpg-signature
cmp
sandcastle
cudd
flex-monkey
microstation
flex4.6
dotnetnuke-7
android-dateutils
fink
design-principles
user-management
inf
dynatree
pypiserver
extjs-grid
text-search
zscript
git-ftp
j-security-check
actionfilterattribute
openbabel
adehabitathr
cosine-similarity
cocos3d
linkedin-jsapi
ignite-ui
grails-plugin-rabbitmq
android-framework
gae-quotas
artemis
windows-phone-8-sdk
observium
cnf
ui-select2
flex++
kaleidoscope
traceability
onload-event
dopostback
vfs
database-create
oracle-enterprise-linux
jquery-tools
catransform3d
tournament
creole
dataform
jqueryform
binomial-heap
sifr
qtabbar
visualj#
escrow
todos
sqlobject
leader

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