diff --git a/docs/en/diagnostics/UsingFindElementByString.md b/docs/en/diagnostics/UsingFindElementByString.md index 0737366e318..5f7d1f1064f 100644 --- a/docs/en/diagnostics/UsingFindElementByString.md +++ b/docs/en/diagnostics/UsingFindElementByString.md @@ -1,20 +1,29 @@ -# Using FindByName, FindByCode and FindByNumber (UsingFindElementByString) +# Using FindByName, FindByCode and FindByNumber (UsingFindElementByString) ## Description -It is forbidden to use the search methods for elements "FindByName" or "FindByCode". +The rule finds the use of the `FindByName`, `FindByCode` or `FindByNumber` methods using specific numbers, codes and names of elements or documents. +Similar code may not work correctly in other databases. +Often such code is test code included in the release version, which is also not recommended. + +It is recommended to specify constant data values ​​from the database in "Сonstants" or predefined metadata elements. ## Examples +Incorrect: ```bsl Position = Catalogs.Positions.FindByName("Senior Accountant"); ``` +or +```bsl +Position = Catalogs.Positions.FindByCode("00-0000001"); +``` or ```bsl -Position = Catalogs.Positions.FindByCode("00-0000001"); +Object = Documents.Invoice.FindByNumber("0000-000001", CurrentDate()); ``` Acceptable use: @@ -24,3 +33,7 @@ Catalogs.Currencies.FindByCode(CurrentData.CurrencyCodeDigital); ```bsl Catalogs.BankClassifier.FindByCode(BankDetails.BIK); ``` + +```bsl +Documents.Invoice.FindByNumber(Number); +```