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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

batch job package import gives an error

(0) ShareShare
ReportReport
Posted on by 1,205
Hello,
 
I have such code which imports DMF package and it works fine when I run it not in batch
 
public class Class1 extends RunBaseBatch
{
    public void run()
    {
          FileUploadTemporaryStorageResult result = this.parmFileUpload();
           
          using(System.IO.MemoryStream stream = result.openResult() as System.IO.MemoryStream)
          using(System.IO.Compression.ZipArchive zipArchive = new System.IO.Compression.ZipArchive(stream))
          {
               while select packageImportStaging
                  where packageImportStaging.PackageName == "Accounts Payable"
               {
                    zipArchiveEntry = zipArchive.GetEntry(strFmt("%1 %2 %3%4zip", packageImportStaging.Sequence, "@SYS77038", 
                                                                  packageImportStaging.PackageName, "@SYS35672"));
                    var unzippedStream = zipArchiveEntry.Open();

                    FileUploadTemporaryStorageResult result2 = File::SendFileToTempStore_GetResult(unzippedStream, zipArchiveEntry.FullName);

                    batchImporter = DMFPackageImporter1::construct();
                    batchImporter.parmDMFDefinitionGroupName(packageImportStaging.PackageName);
                    batchImporter.parmDMFSourceName("Package");
                    batchImporter.parmFileUpload(result2);
                    
                    batchImporter.run();
                }
          }


    }
}
DMFPackageImporter1 run() code
 
public void run()
{
    DMFDefinitionGroupName           definitionGroupNameLoc      = this.parmDMFDefinitionGroupName();
    DMFDefinitionGroupName           definitionGroupNameProject  = "@SYS1052" + " " + definitionGroupNameLoc;
    FileUploadTemporaryStorageResult result                      = this.parmFileUpload();
    
    info("line 90");

    var packageFilePath = result.getFileId();

    info("line 94");

        DMFEntityBase::addEntityForProcessingV3(
                    definitionGroupNameProject,
                    definitionGroupNameProject,
                    "",
                    this.parmDMFSourceName(),
                    packageFilePath,
                    "",
                    NoYes::No,
                    NoYes::No
                    );

    info("line 103");

        //Setting up an execution Id to link the DIXF Project to an execution
        DMFExecutionId executionId = DMFUtil::setupNewExecution(definitionGroupNameProject);
 
        //Begin the execution on the DIXF Project
        DMFQuickImportExport::doPGImport(definitionGroupNameProject, executionId, true, false);
}
When I run it in batch like that 
 
public class Class1 extends RunBaseBatch
{
    public void run()
    {
          FileUploadTemporaryStorageResult result = this.parmFileUpload();

           //create batch header
           batchHeader = BatchHeader::construct();
           batchHeader.parmCaption("Import DMF Packages");
           
          using(System.IO.MemoryStream stream = result.openResult() as System.IO.MemoryStream)
          using(System.IO.Compression.ZipArchive zipArchive = new System.IO.Compression.ZipArchive(stream))
          {
               while select packageImportStaging
                  where packageImportStaging.PackageName == "Accounts Payable"
               {
                    zipArchiveEntry = zipArchive.GetEntry(strFmt("%1 %2 %3%4zip", packageImportStaging.Sequence, "@SYS77038", 
                                                                  packageImportStaging.PackageName, "@SYS35672"));
                    var unzippedStream = zipArchiveEntry.Open();

                    FileUploadTemporaryStorageResult result2 = File::SendFileToTempStore_GetResult(unzippedStream, zipArchiveEntry.FullName);

                    batchImporter = DMFPackageImporter1::construct();
                    batchImporter.parmDMFDefinitionGroupName(packageImportStaging.PackageName);
                    batchImporter.parmDMFSourceName("Package");
                    batchImporter.parmFileUpload(result2);
                    
                    batchHeader.addTask(batchImporter);
                }
               batchHeader.save();
          }
    }
}
 
it never reaches  info("line 94"); line code in the DMFPackageImporter1.run() method. 
 
 
so as far as i understand the issue happens on the line 
 
var packageFilePath = result.getFileId();
 
in the DMFPackageImporter1.run()
 
The parameters I have passed don't come to the instance of the DMFPackageImporter1. That's why I get this error. Why this can happen?
 
Thank you.
 
 
I have the same question (0)
  • Verified answer
    Anthony Blake Profile Picture
    3,131 Super User 2026 Season 1 on at
     
    You are getting result from parmFilePath(), are you packing and unpacking you parameters for batch? The object referenced not set to an instance of an object suggests that parmFilePath() is null.
     
    Anthony 
  • dark_knight Profile Picture
    1,205 on at
     
    Thanks. There was an error in my pack() method. I fixed it and it worked fine then.
  • Anthony Blake Profile Picture
    3,131 Super User 2026 Season 1 on at
    @dark_knight excellent thanks for confirming

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 738

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 453 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 286 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans