Hi,
Error detected,
how to fix the error that micro sales id is not defined in d365 f&o
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.
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.
Thanks,
and suppose if we want to execute this without macro then whether it is possible
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.
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();
}
}
}
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
HI MR,
Can you be more elaborate?
If possible, can you share your piece of code where the error is throwing.
Thanks,
Girish S.
André Arnaud de Cal...
291,971
Super User 2025 Season 1
Martin Dráb
230,846
Most Valuable Professional
nmaenpaa
101,156