23
Using WITH statements in combination with function parameters can often lead to errors, since the WITH statement is using the record 'field' instead of the - by the developer intended - function parameter.
In the function below, it would be interesting to have a CodeCop rule to alert to refactor the code by either removing the WITH statement, either by renaming the function parameter 'Code' to 'NewCode' or 'PaymentTermsCode' to improve readibility / avoid future conflicts.
CreatePaymentsTerms(Code : Code[10])
WITH PaymentTerms DO BEGIN
INIT;
Code := Code;
...
END;
In the function below, it would be interesting to have a CodeCop rule to alert to refactor the code by either removing the WITH statement, either by renaming the function parameter 'Code' to 'NewCode' or 'PaymentTermsCode' to improve readibility / avoid future conflicts.
CreatePaymentsTerms(Code : Code[10])
WITH PaymentTerms DO BEGIN
INIT;
Code := Code;
...
END;
STATUS DETAILS
Needs Votes
Business Central Team (administrator)
Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future.
Best regards,
Business Central Team