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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Error

(0) ShareShare
ReportReport
Posted on by 123

Hi,

Error detected,

how to fix the error that micro sales id is not defined in d365 f&o

I have the same question (0)
  • GirishS Profile Picture
    27,829 Moderator on at

    HI MR,

    Can you be more elaborate?

    If possible, can you share your piece of code where the error is throwing.

    Thanks,

    Girish S.

  • Mohit Rampal Profile Picture
    12,565 Moderator on at

    Error is not a good title for this post. Please change it as well so someone facing same issue can find it easily in future.

    You have compilation errors in your code so better share full code.

    Also, your run method is incorrect, you should be calling these methods with 'this' keyword. 

    Instead of getFromDialog use this.getFromDialog

  • M_R Profile Picture
    123 on at

    class SalesOrderDeleteBatchJob extends RunBaseBatch

    {

       DialogRunbase dialog;

       SalesId salesId;

       str fileName;

       str tableName;

       str relationName;

       SalesTable salesTable;

       SalesLine salesLine;

       SalesLineDelete salesLineDelete;

       SalesTableDelete salesTableDelete;

       Map mapTables;

       Map mapRelations;

       MapEnumerator mapTablesEnumerator;

       MapEnumerator mapRelationsEnumerator;

       public static void main(Args _args)

       {

           SalesOrderDeleteBatchJob salesOrderDeleteBatchJob = new SalesOrderDeleteBatchJob();

           salesOrderDeleteBatchJob.run();

       }

         public void dialog()

       {

           dialog = DialogRunbase::construct();

           dialog.caption("Delete Sales Orders Batch Job");

           dialog.addFieldValue(extendedTypeStr(SalesId), salesId, "Sales ID");

           dialog.addFieldValue(extendedTypeStr(FilenameOpen), fileName, "Excel File");

           dialog.run();

       }

       public boolean getFromDialog()

       {

           salesId = dialog.fieldValue(extendedTypeStr(SalesId));

           fileName = dialog.fieldValue(extendedTypeStr(FilenameOpen));

           return true;

       }

       public void mapTablesAndRelations()

       {

           mapTables = new Map(Types::String, Types::String);

           mapRelations = new Map(Types::String, Types::String);

           mapTables.insert("SalesTable", "SalesLine");

           mapTables.insert("SalesLine", "");

           mapRelations.insert("SalesTable", "SalesLine");

       }

       public void deleteSalesOrder()

       {

           salesTable = SalesTable::find(salesId);

           salesTableEnumerator = salesTable.getEnumerator();

           while (salesTableEnumerator.moveNext())

           {

               tableName = salesTableEnumerator.currentName();

               if (mapTables.exists(tableName))

               {

                   salesLineEnumerator = salesTableEnumerator.currentValue().getEnumerator();

                   while (salesLineEnumerator.moveNext())

                   {

                       salesLine = salesLineEnumerator.currentValue();

                       if (mapTables.get(tableName) == "SalesLine")

                       {

                           salesLineDelete = SalesLineDelete::construct(salesLine);

                           salesLineDelete.run();

                       }

                       else

                       {

                           salesLineUpdate = SalesLineUpdate::construct(salesLine);

                           salesLineUpdate.run();

                       }

                   }

                   if (mapRelations.exists(tableName))

                   {

                       relationName = mapRelations.get(tableName);

                       salesTableDelete = SalesTableDelete::construct(salesTable);

                       salesTableDelete.run();

                   }

                   else

                   {

                       salesTableUpdate = SalesTableUpdate::construct(salesTable);

                       salesTableUpdate.run();

                   }

               }

               else

               {

                   salesTableInsert = SalesTableInsert::construct(salesTable);

                   salesTableInsert.run();

               }

           }

               public container pack()

           {

               return [#File fileName, #SalesId salesId];

           }

           public boolean unpack(container, _packedClass)

           {

               fileName = conPeek(_packedClass, 1);

               salesId = conPeek(_packedClass, 2);

               return true;

           }

           public void run()

           {

               dialog();

               if (getFromDialog())

               {

                   mapTablesAndRelations();

                   deleteSalesOrder();

               }

        }

    }

  • Suggested answer
    GirishS Profile Picture
    27,829 Moderator on at

    You need to call the method inside the class using this keyword. Also check whether you have closed and opened all the braces.

    For initializing pack and unpack variables refer to the standard class like PayrollEarningStatementGeneration. You must define macro globally in the class and then use it in pack and unpack method.

    Thanks,

    Girish S.

  • M_R Profile Picture
    123 on at

    Thanks,

    and suppose if we want to execute this without macro then whether it is possible

  • GirishS Profile Picture
    27,829 Moderator on at

    You can go without pack and unpack method but its mandatory to add pack and unpack method when you are creating batch classes.

    Thanks,

    Girish S.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    You should add closing brace } in the end of code then you get all the compilation errors you have in the code.

    You should review your entire code as its incorrect. For instance, use Object as return type in Dialog method instead of void.

    Please check this article and change your code.

    daxingwitheshant.blogspot.com/.../how-to-create-dialog-form-by-extending.html 

    Compilation errors should be fixed like variables SalesTableEnumerator, salesLineEnumerator are not declared etc.

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…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 438 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 354 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans