I was getting the below error while using ChainOfCommands (CoC) in D365fO to hook up a standard method.
call to 'next' should be done only once and unconditionally
This issue has been started after upgrading to 10.0.* version.
Reason:
Notice the return false; statements in the middle. Those are the parts which disturbs the compiler because the code returns before the call of next.
Solution:
In my case I used ret = false; instead of return false.
Ex:
[ExtensionOf(classStr(LedgerJournalFormTable))]
final class LedgerJournalFormTableROBS_Extension
{
public boolean verifyCanDelete(boolean _suppressPrompt)
{
Dialog dlg = new Dialog("@XXX189");
DialogField executeField;
DialogText informationField;
var ret = false;
LedgerJournalTable ledgerJournalTable = this.journalTable() as LedgerJournalTable;
if (!_suppressPrompt && ledgerJournalTable.ROBS_FIELD)
{
informationField = dlg.addText("@XXX193");
dlg.addText("@XXX190");
executeField = dlg.addField(extendedTypeStr(Name));
executeField.showLabel(false);
if (dlg.run())
{
if (strUpr(executeField.value()) != strFmt("@XXX191"))
{
error("@XXX192");
ret = false;
}
}
else
{
error("@XXX192");
ret = false;
}
}
var std_ret = next verifyCanDelete(_suppressPrompt);
return std_ret && ret;
}
}
For more details:
https://robscode.onl/d365-chainofcommands-call-to-next-should-be-done-only-once-and-unconditionally/
No comments:
Post a Comment