web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Batch task failed: Object reference not set to an instance of an object

(1) ShareShare
ReportReport
Posted on by 49
I am trying to make batch job but every time I run it I get this error log
any batch give the same error even as sample as this batch: 
 DialogField dialogMyParameter;

    str myParameter = "Default value";

    #define.CurrentVersion(1)
    #localmacro.CurrentList
        myParameter
    #endmacro

    public container pack()
    {
        // This method is used by batch platform to serialize batch parameters in a container
        return [#CurrentVersion, #CurrentList];
    }

    public boolean unpack(container _packedClass)
    {
        // This method is used by batch platform to deserialize batch parameters from stored 
        // batch parameter container

        Integer version = RunBase::getVersion(_packedClass);
        container packedData;

        switch (version)
        {
            case #CurrentVersion:
                [version, #CurrentList] = _packedClass;
                break;
            default:
                return false;
        }

        return true;
    }

    public Object dialog()
    {
        // This method is invoked when user opens batch parameter dialog
        // It helps to add parameters to batch class and set their default value

        DialogRunbase dialog = super();

        dialogMyParameter = dialog.addField(enum2Str(Types::Integer), "My Parameter");

        // Set a default value of parameter
        dialogMyParameter.value(myParameter);

        return dialog;
    }

    public boolean getFromDialog()
    {
        // This method is invoked by batch platform to read the values of parameters from batch 
        // parameter dialog method
        myParameter = dialogMyParameter.value(); 

        return super();
    }

    public void run()
    {
        // This method is the entry point for the batch class

        info("Batch job started!");
        // Access the parameter value entered by the user
        info("My Parameter: " + this.myParameter);
        // Your main batch logic goes here
        info("Batch job completed!");
    }

    public static void main(Args _args)
    {
        // This method is used to create an instance of the batch class, prompt the user 
        // for input using dialog, and then execute the batch job using run().

        MyBatchClass batch = new MyBatchClass();
        if (batch.prompt())
        {
            batch.run();
        }
    }
 
Categories:
I have the same question (0)
  • Kareem Profile Picture
    49 on at
    Batch task failed: Object reference not set to an instance of an object.
    note:
    this error only show up when I tick this
  • Martin Dráb Profile Picture
    236,640 Most Valuable Professional on at
    Batch task failed: Object reference not set to an instance of an object.
    You can use the debugger to find out where the error comes from. Note that you'll likely need to attach the debugger to batch.exe.
     
    Of course, make sure that your application is fully compiled. Also, you should think about what changed at (before) the moment when the error start occurring.
  • Anton Venter Profile Picture
    20,301 Super User 2025 Season 2 on at
    Batch task failed: Object reference not set to an instance of an object
    In addition to what Martin has said. Is the code complete? Looking at the code, I don't see any reason why this code would throw an "Object reference not set to an instance of an object" error. Is it extending from RunbaseBatch?
  • Layan Jwei Profile Picture
    8,058 Super User 2025 Season 2 on at
    Batch task failed: Object reference not set to an instance of an object
    Hi,

    Please debug as Martin said and let us know where it fails exactly.
  • Verified answer
    Kareem Profile Picture
    49 on at
    Batch task failed: Object reference not set to an instance of an object
    The main problem was because I was extending RunbaseBatch when I changed to sysoperation it got solved thanks guys

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 796

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 721 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 530 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans