Anybody tried to use record sorted list class as I am trying to iterate over it or copy it to another recordSortedList but I always get object reference null so please help if anybody gets stuck with it .
Anybody tried to use record sorted list class as I am trying to iterate over it or copy it to another recordSortedList but I always get object reference null so please help if anybody gets stuck with it .
I didn't say anything about changing a standard class.
Your first step should be identifying the place throwing the exception. Use the debugger for that, as suggested above. When you know which reference is null, look at why it's null.
Most likely you're passing wrong parameters to the method. For example, your handling of dimensions look pretty suspicious. But let's not guess - debug the code instead.
i only call this method and it is a standard class in AX so how possible could i change it?
Aha, so you didn't give us complete code before. :-(
Please use the debugger to find out where the exception is thrown and which variable is responsible for it. It seems it's somewhere inside AssetTransferBalancing.assetTransfer() method, not in any code you've shared so far.
By the way, why didn't use Insert > Insert Code (in the rich-formatting view) to paste source code? If you don't know how, feel free to ask.
No, i already initiate it in the following code below:
public boolean init()
{
boolean ret;
assetBookList=new RecordSortedList(tableNum(AssetBook));
assetBookList.sortOrder(fieldNum(AssetBook,RecId));
assetTransfer= AssetTransferBalancing::construct();
ret = super();
return ret;
}
Please read my reply more carefully. I said you don't initialize assetTransfer variable, not a RecordSortedList.
You do initialize a list, but as I said, it's empty, because you've just created it. It has nothing to do with the object you received from _args.parmObject().
I already initiate recordsortedList in the run method so u mean that I shouldn't initiate it in this method
Please always use Insert > Insert Code (in the rich-formatting view) to paste source code. Let me do it for you this time.
First code snippet:
class FixedAssetsBatch extends RunBaseBatch { AssetTransferBalancing assetTransfer; RecordSortedList assetBookList; Str60 defaultDimension; } public static void main(Args _args) { RecordSortedList myRecordSortedList=new RecordSortedList(tableNum(AssetBook)); FixedAssetsBatch _FixedAssetsBatch = FixedAssetsBatch::construct(); myRecordSortedList=_args.parmObject(); _FixedAssetsBatch.assetBookListpar(myRecordSortedList); _FixedAssetsBatch.defaultDim(_args.parm()); _FixedAssetsBatch.getLast(); _FixedAssetsBatch.caption(); _FixedAssetsBatch.run(); } public void run() { RecordSortedList list= new RecordSortedList(tableNum(AssetBook)); list.sortOrder(fieldNum(AssetBook,recid)); list=assetBookList; }
Note that this code doesn't show any iteration of a list at all. You create a RecordSortedList, then you overwrite it (therefore the initialization can be thrown away) and you pass it to FixedAssetsBatch. That's it. The run() method does nothing useful at all, it just creates an empty list and assign it to two variables.
The latter snippet:
if (!assetTransfer.transferAsset(list, str2int64(defaultDimension), today(), 'Handled by Batch Job')) { throw error("@SYS4005928"); }
You never initialize assetTransfer variable, therefore it's null. As I told you in my previous reply, you get an exception when you're trying to call methods on null objects. I also told you that you can use the debugger to check if a value is null. Make sure you learn how to do it, so you can find such bugs by yourself next time.
I also checked list buffer to make sure that it has values as i set a condition (if list.len()>1) do some actions and it accesses the method but the error keeps hitting so please advise
this code is in the run method() and when i run this code below and it gives the object reference in this highlighted one but at the same time, i checked the recordSortedList from arg.parms and it doesnt return null so please help
if (!assetTransfer.transferAsset(list,str2int64(defaultDimension),today(),'Handled by Batch Job'))
{
throw error("@SYS4005928");
}
yes, it is args.parmObject() and am trying to call it in the batch with the following lines below:
class FixedAssetsBatch extends RunBaseBatch
{
AssetBook assetBook;
AssetTransferBalancing assetTransfer;
RecordSortedList assetBookList;
Str60 defaultDimension;
QueryRun gQueryRun;
#define.CurrentVersion(1)
}
public static void main(Args _args)
{
RecordSortedList myRecordSortedList=new RecordSortedList(tableNum(AssetBook));
FixedAssetsBatch _FixedAssetsBatch = FixedAssetsBatch::construct();
myRecordSortedList=_args.parmObject();
_FixedAssetsBatch.assetBookListpar(myRecordSortedList);
_FixedAssetsBatch.defaultDim(_args.parm());
_FixedAssetsBatch.getLast();
_FixedAssetsBatch.caption();
_FixedAssetsBatch.run();
}
public void run()
{
RecordSortedList list= new RecordSortedList(tableNum(AssetBook));
list.sortOrder(fieldNum(AssetBook,recid));
list=assetBookList;
}
André Arnaud de Cal...
294,261
Super User 2025 Season 1
Martin Dráb
233,017
Most Valuable Professional
nmaenpaa
101,158
Moderator