Skip to main content

Notifications

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

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Error

    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.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Error

    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.

  • M_R Profile Picture
    M_R 123 on at
    RE: Error

    Thanks,

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

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Error

    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
    M_R 123 on at
    RE: Error

    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();

               }

        }

    }

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Error

    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

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Error

    HI MR,

    Can you be more elaborate?

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

    Thanks,

    Girish S.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans