Monday 12 August 2019

call to 'next' should be done only once and unconditionally in Dynamics 365 F&O while using extensions(CoC's)

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: 


No comments:

Post a Comment

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...